如何在没有构建全局的情况下访问函数内部的变量?

时间:2011-09-07 07:24:46

标签: php declare

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

1 个答案:

答案 0 :(得分:0)

我不是100%确定你想要做什么但是

  

例如,在Joomla中为此更改页面底部页面底部的标签1)您必须下载托管转储脚本2)查找旁边的一段html脚本代码3)调查行为函数4)找一个地方html代码教育我需要几个小时才能找到$ globals和register_tick_function的帮助

听起来像

如果您需要调试应用程序和/或需要查看以什么顺序和使用什么参数调用哪些函数和方法,请使用正确的调试器:

请参阅https://stackoverflow.com/questions/1494288/good-free-php-debugger

  

非常感谢,但是在hostmonster.com中禁用了xdebug

想要调试您的生产网站。如果需要添加更多功能或应用更改,请首先在开发服务器上执行此操作。确保它有效,然后将更改部署到生产站点。因此,要么将XDebug放在本地计算机上,要么放入VM或类似的东西。或者为您的开发环境获得一个新的主机。无论如何,把它放在开发和调试不会破坏生产的地方。

相关问题