我有一个头的方法,显示在页面的顶部,它是一个类里面,我的头()方法中我在这里运行此代码启动一个新的探查物体......如何解决这个PHP错误?
//start new page timer object
$profiler = new Profiler;
$profiler->start();
后一堆其他文件进行编译,然后我有一个文件到页脚部分,在该文件中运行此代码,
echo 'Page Generated in ' .$profiler->end(). ' of a second with ' .$_SESSION['querie_counter']. ' MySQL Queries';
但是我在现在的页脚文件收到此错误信息,
Notice: Undefined variable: profiler in C:\webserver\htdocs\friendproject2\includes\footer.inc.php on line 21
Fatal error: Call to a member function end() on a non-object in C:\webserver\htdocs\friendproject2\includes\footer.inc.php on line 21
我怎样才能解决这个问题?在一个函数创建
365的问题,恭喜! – 2010-01-18 05:27:13
你几乎问这个_exact相同question_昨天:HTTP://计算器。com/questions/2080369/can-i-have-a-class-method-include-a-header-file-for-me-in-php 你不明白什么? – hobodave 2010-01-18 05:40:45
请阅读http://php.net/manual/en/language.variables.scope.php两次。 – hobodave 2010-01-18 05:41:37