can any one please let me know the basic differences between
$GLOBALS["test"] and global $test
and, will it make sense that, if i use
$GLOBALS["test"] instead of
and, will it make sense that, if i use $GLOBALS["test"] instead of $_SESSION['test']?</blockquote>
No, <strong><a href="http://www.php.net/manual/en/intro.session.php" rel="nofollow">session</a></strong> is different thing from a variable that is available globally.
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.</blockquote>
<a href="http://php.net/manual/en/reserved.variables.globals.php" rel="nofollow">http://php.net/manual/en/reserved.variables.globals.php</a>
$GLOBALS is an associative array available throughout your script, there is no need to use
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.</blockquote> Answer2:
There is no difference between
global $test. Both are pure evil and shouldn't be used.
$testis supposed to store an information about something, let's say: number of balls. Everything is fine until there is such a variable and it store what it's suppose to store. However what happen if you decide to delete that variable or use it for other purpose? Bah, fatal errors pop out of nowhere! You don't know what's going on, everything worked fine, you just change a variable's value and everything is falling apart.</li> </ol>