|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-09-07 16:22 UTC] jurciks66 at inbox dot lv
Description: ------------ Copy and run code from manual about $GLOBALS (http://php.net/manual/en/reserved.variables.globals.php) Actual output is: $foo in global scope: $foo in current scope: local variable Expected result: ---------------- I`m expecting to see the same output as seen on documentation page PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 09:00:01 2025 UTC |
[2010/09/07 15:23:31] [Z:\] [\\richardquadling\scratch$ ] >php <?php function test() { $foo = "local variable"; echo '$foo in global scope: ' . $GLOBALS["foo"] . "\n"; echo '$foo in current scope: ' . $foo . "\n"; } $foo = "Example content"; test(); ?> ^Z $foo in global scope: Example content $foo in current scope: local variable Code and example output agree.well, sorry about wrong problem description. my test file was parsed by another file, so, actual test script would look like this - <?php function test2() { function test() { $foo = "local variable"; echo '$foo in global scope: ' . $GLOBALS["foo"] . "\n"; echo '$foo in current scope: ' . $foo . "\n"; } $foo = "Example content"; test(); } test2(); ?> So I`m still wondering why my output is - $foo in global scope: $foo in current scope: local variable