note 110415 added to reserved.variables.globals
| From: | sergei dot solomonov at gmail dot com | Date: | Sat, 20 Oct 2012 10:34:20 +0000 |
| Subject: | note 110415 added to reserved.variables.globals | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191439@lists.php.net to get a copy of this message | ||
<?php
$string = '';
${'123'} = '';
function test()
{
$GLOBALS['string'] = 'string';
$GLOBALS['string2'] = 'string2'; // not declared
$GLOBALS['123'] = '123';
$GLOBALS['456'] = '456'; // not declared
}
test();
var_dump(
$string, // string(6) "string"
${'123'}, // string(0) ""
$string2, // string(7) "string2"
${'456'}, // NULL + notice: Undefined variable: 456
$GLOBALS['123'], // string(3) "123"
$GLOBALS['456'] // string(3) "456"
);
?>
Example 2:
<?php
function test2()
{
$GLOBALS['123'] = '123';
global ${'123'};
${'123'} = '!!!';
}
test2();
var_dump(
$GLOBALS['123'], // string(3) "123"
${'123'} // string(3) "!!!"
);
----
Server IP: 69.147.83.199
Probable Submitter: 83.246.218.42
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.globals.php
Edit -- https://master.php.net/note/edit/110415
Del: integrated -- https://master.php.net/note/delete/110415/integrated
Del: useless -- https://master.php.net/note/delete/110415/useless
Del: bad code -- https://master.php.net/note/delete/110415/bad+code
Del: spam -- https://master.php.net/note/delete/110415/spam
Del: non-english -- https://master.php.net/note/delete/110415/non-english
Del: in docs -- https://master.php.net/note/delete/110415/in+docs
Del: other reasons-- https://master.php.net/note/delete/110415
Reject -- https://master.php.net/note/reject/110415
Search -- https://master.php.net/manage/user-notes.php