note 108872 added to language.variables.scope
| From: | Anonymous | Date: | Thu, 31 May 2012 12:02:23 +0000 |
| Subject: | note 108872 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188320@lists.php.net to get a copy of this message | ||
I don't pretend to understand this, but there is something strange when you define or reassign
a variable within a statement vs at the top level:
fileA:
if ( "somecondition" )
$IS_TEST_MODE=TRUE;
else
$IS_TEST_MODE=FALSE;
require "fileB";
fileB:
echo "Test mode='{$IS_TEST_MODE}'";
I expected it to echo
Test mode = '1'
or Test mode = '0'
but instead it is
Test mode = ''
Assignment from the top level does work like expected, so there seems to be something about
assignment that affects variable visibility.
----
Server IP: 69.147.83.197
Probable Submitter: 152.14.95.61
----
Manual Page -- http://www.php.net/manual/en/language.variables.scope.php
Edit -- https://master.php.net/note/edit/108872
Del: integrated -- https://master.php.net/note/delete/108872/integrated
Del: useless -- https://master.php.net/note/delete/108872/useless
Del: bad code -- https://master.php.net/note/delete/108872/bad+code
Del: spam -- https://master.php.net/note/delete/108872/spam
Del: non-english -- https://master.php.net/note/delete/108872/non-english
Del: in docs -- https://master.php.net/note/delete/108872/in+docs
Del: other reasons-- https://master.php.net/note/delete/108872
Reject -- https://master.php.net/note/reject/108872
Search -- https://master.php.net/manage/user-notes.php