How to access a variable inside a function without the construction of a global?

StackOverflow https://stackoverflow.com/questions/7330232

  •  27-10-2019
  •  | 
  •  

Question

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

How print //This not print ,but without global $a ?

And without

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
}
Was it helpful?

Solution

I am not 100% sure what you are trying to do but

For example, in Joomla to change the label prescribed bottom of the page bottom of page for this 1) You must download hosting dump script 2) Find a piece of html script code that is next to 3) To investigate the behavior of functions 4) Find a place html code education It takes a couple of hours I just find with the help of $globals and register_tick_function

sounds like .

If you need to debug your application and/or need to see which functions and methods got called in what order and with what parameters, then use a proper debugger:

See https://stackoverflow.com/questions/1494288/good-free-php-debugger

Big Thanks, but xdebug in hostmonster.com disabled

You do not want to debug your production site. If you need to add more features or apply changes, do so on your development server first. Make sure it works, then deploy the changes to your production site. So either put XDebug on your local machine or into a VM or anything like that. Or get a new hoster for your development environment. In any case, put it where development and debugging wont disrupt production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top