Skip to content

Instantly share code, notes, and snippets.

@jaikdean
Created February 14, 2013 11:00
Show Gist options
  • Save jaikdean/4952061 to your computer and use it in GitHub Desktop.
Save jaikdean/4952061 to your computer and use it in GitHub Desktop.
Testing whether PHP hoists `global` statements
<?php
$foo = 'set globally';
function testGlobals()
{
$foo = 'set locally';
global $foo;
}
testGlobals();
echo "$foo\n";
// outputs "set globally"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment