如何在 class.php 个文件中使用 FirePHP?

How do I use FirePHP in class.php files?

我刚刚开始学习 OOP 和 PSR-4 自动加载 class 文件到我的项目中。到目前为止一切顺利,但我依赖 FirePHP。 FirePHP 在我的主要脚本中运行良好,但如果我尝试在 class 文件中使用 FirePHP,它根本不起作用:

<?php namespace App\cmd;

class help
{
    public $test = "Test successful!";
    function __construct() {
        FB::info('HELP CLASS WAS CALLED!');
    }
}

我尝试了各种方法来让它发挥作用;尝试包含 fb.php 而不是尝试包含 ob_start(),添加 error_handler 和不添加 error_handler。似乎没有任何效果。

<?php namespace App\cmd;
ob_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/FirePHPCore/fb.php');
set_error_handler('myErrorHandler');
set_exception_handler('myExceptionHandler');

function myErrorHandler($errno, $errstr, $errfile, $errline)
     {FB::error($errstr, 'Error number' . $errno . ' in ' . $errfile . ' at ' . $errline);}

function myExceptionHandler($errno, $errstr, $errfile, $errline)
    {FB::error($errstr, 'Exception number' . $errno . ' in ' . $errfile . ' at ' . $errline);}

class help
{
    public $test = "Test successful!";
    function __construct() {
        FB::info('HELP CLASS WAS CALLED!');
    }
}

我得到的错误是:

PHP Parse error:  syntax error, unexpected 'FB' (T_STRING), expecting function (T_FUNCTION) in help.php 

PHP Fatal error:  Class 'App\cmd\FB' not found in help.php

我一定是在做一些非常愚蠢的事情,你能告诉我在 class 个文件中使用 FirePHP 需要做什么吗?

评论正确,谢谢。我只需要正确命名 FirePHP:

<?php namespace App\cmd;
use \FB as FB;
class help
{
    public $prop1 = "Command test successful!";
    function __construct() {
    FB::warn('HELP CLASS WAS CALLED!');
    }
}