$GLOBALS
Submitted by admin on Sun, 11/20/2011 - 16:31
$GLOBALS — References all variables available in global scope
An associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.
<?php
function test() {
$foo = "local variable";
echo '$foo in global scope: ' . $GLOBALS["foo"] . "\n";
echo '$foo in current scope: ' . $foo . "\n";
}
$foo = "Example content";
test();
?>
o/p:
$foo in global scope: Example content
$foo in current scope: local variable
»
- admin's blog
- Login or register to post comments
