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


How do I use FirePHP in class.php files?

我刚刚开始学习OOP和PSR-4自动加载类文件到我的项目。到目前为止一切顺利,但我依赖于FirePHP。FirePHP在我的主脚本中工作得很好,但如果我试图在类文件中使用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而不带。

<?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

我一定是做了一些非常愚蠢的事情,你能告诉我我需要做些什么来使用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!');
    }
}