note 110415 deleted from reserved.variables.globals by aharvey
| From: | aharvey@php.net | Date: | Mon, 22 Oct 2012 02:49:05 +0000 |
| Subject: | note 110415 deleted from reserved.variables.globals by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191461@lists.php.net to get a copy of this message | ||
Note Submitter: sergei dot solomonov at gmail dot com
----
<?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) "!!!"
);