Well, you should only use globals in limited circumstances, but to answer your question:
globalis potentially marginally faster (it will rarely make a difference).$GLOBALS(not$GLOBAL) is more readable, because every time you see it, you know you are accessing/changing a global variable. This can be crucial in avoiding nasty bugs.- Inside the function, if you want to unset a global variable, you must use
unset($GLOBALS['varname']), notglobal $varname; unset($varname);.
As to points 1 and 2, I’ll quote Sara Golemon here:
What does that mean for your use of the
$GLOBALSarray? That’s right, theglobalkeyword is technically faster. Now, I want to be really clear about one thing here. The minor speed affordance given by using your globals as localized [compiled variables] needs to be seriously weighed against the maintainability of looking at your code in five years and knowing that$foocame from the global scope.something_using($GLOBALS['foo']);will ALWAYS be clearer to you down the line thanglobal $foo; /* buncha code */ something_using($foo);Don’t be penny-wise and pound foolish..