Query: globals
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
GLOBALS(3) 1 GLOBALS(3) $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. Example #1 $GLOBALS example <?php function test() { $foo = "local variable"; echo '$foo in global scope: ' . $GLOBALS["foo"] . " "; echo '$foo in current scope: ' . $foo . " "; } $foo = "Example content"; test(); ?> The above example will output something similar to: $foo in global scope: Example content $foo in current scope: local variable Note This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods. Note Variable availability Unlike all of the other superglobals, $GLOBALS has essentially always been available in PHP. PHP Documentation Group GLOBALS(3)
Related Man Pages |
---|
scope(n) - mojave |
scope(546) - suse |
session_register(3) - php |
runkit_sandbox_parent(3) - php |
unset(3) - php |
Similar Topics in the Unix Linux Community |
---|
perl: globals and a package. |
how to access globals in a function |
Php server globals REQUEST_URI or HTTP_SERVER_VARS |