global Overwrites

../_images/global_overwrite.png

The global keyword is actually enough to overwrite a local variable.

In this illustration, the default value is used to trigger fetching the global variable $argv. The instruction is alone in the block, but it actually replaces the current variable, aka the parameter, by the global one. No assignation in sight, merely a surprise.

This won’t work with superglobal, such as $_POST, which can’t be overwritten by a parameter.

See Also

PHP Error Messages

PHP Features