faqts : Computers : Programming : Languages : PHP : General Information : PHP5

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 5 people (60%) answered Yes
Recently 3 of 5 people (60%) answered Yes

Entry

Why does GLOBALS['GLOBALS'] ... exists in PHP 5.0.4? What purpose does it have? Bug?

Oct 8th, 2006 10:05
Matthew Wilkinson, DDA 776, http://uk.php.net/manual/en/reserved.variables.php#reserved.variables.globals


$GLOBALS is an automatically updated array that contains ABSOLUTELY
every single variable in the global scope of the currently running
script. Since every variable is included, it includes itself, since it
is in the global scope. Be careful when iterating through it as
$GLOBALS['GLOBALS'] is infinitely recursive, eg.
$GLOBALS['GLOBALS']['GLOBALS']['GLOBALS']......
No this is not a bug in the PHP engine, it is purposefully placed there.