【发布时间】:2011-09-07 07:24:46
【问题描述】:
<?php
declare(ticks=1);
function tick_handler()
{
print($GLOBALS['a']);
}
register_tick_function('tick_handler');
function test()
{
$a = 1;//This not print
$a = 2;//This not print
$a = 3;//This not print
$a = 4;//This not print
}
test();
$a = 1;//This print
$a = 2;//This print
$a = 3;//This print
$a = 4;//This print
?>
如何打印 //这不是打印,而是没有全局$a?
没有
function test()
{
$GLOBALS['a'] = 1;//This not print
$GLOBALS['a'] = 2;//This not print
$GLOBALS['a'] = 3;//This not print
$GLOBALS['a'] = 4;//This not print
}
【问题讨论】:
-
这里没有办法做你想做的事。但是为什么?必须有更好的方法来做你想做的事。就我个人而言,我从未在实际代码中见过
register_tick_function。 -
值班时,我必须使用一些 CMS,直到您找到形成 HTML 代码的确切位置需要几个小时,尤其是在调用类和函数时。因此,有必要编写代码以使用脚本引擎。我想看看一个文件、字符串、变量究竟是什么构成了一段 HTML 代码
-
这听起来像是在寻找 XDebug。
-
例如,在Joomla中将页面底部的标签更改为页面底部为这个 1)您必须下载托管转储脚本 2)找到一段html脚本代码,旁边是3)调查函数的行为 4) 找到一个地方 html 代码教育 我只是在 $globals 和 register_tick_function 的帮助下找到了几个小时
-
是的,使用 XDebug:xdebug.org