Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php FireHP、类文件和';未定义变量';_Php_Firebug_Firephp - Fatal编程技术网

Php FireHP、类文件和';未定义变量';

Php FireHP、类文件和';未定义变量';,php,firebug,firephp,Php,Firebug,Firephp,这是一个非常愚蠢的问题,但我没有可以求助的php朋友,我很难过;-) 所以我有这个设置,我刚刚安装了FireHP: /lib/firephp.php // firephp standard library /lib/data.php // a php class file of my own | |-> Class Data {} // this is the class function somethi

这是一个非常愚蠢的问题,但我没有可以求助的php朋友,我很难过;-)

所以我有这个设置,我刚刚安装了FireHP:

/lib/firephp.php   // firephp standard library
/lib/data.php      // a php class file of my own
        |
        |-> Class Data {}   // this is the class
                  function something() { $firephp->log('whatever'); }
pre.php            // here i initialize firephp
show_data.php      // i show data from the database here


---
pre.php
---
require_once($_SERVER['DOCUMENT_ROOT'] . '/intranet/lib/firephp.php');
ob_start();
$firephp = FirePHP::getInstance(true);

---
show_data.php
---
include('pre.php')
include('lib/data.php')
$c = new Data
$c->something()
我发现:注意:show_data.php中的未定义变量:firephp

TL;DR我在一个包含文件中初始化FireHP,然后包含我的类文件,当我试图从类内部调用它时,它无法读取$FireHP var


非常感谢您给我的任何提示、责骂或任何帮助。

我找到了一个很好的方法:

在pre.php中,我创建了一个创建$firephp对象的函数,然后在show_data.php中调用它

---
pre.php
---
require_once($_SERVER['DOCUMENT_ROOT'] . '/intranet/lib/firephp.php');
ob_start();

function mylog($var, $other = '') {
    $firephp = FirePHP::getInstance(true);
    $firephp->log($var, $other);
}


---
show_data.php
---
include('pre.php')
include('lib/data.php')
mylog('whatever');
这管用