note 101396 added to reserved.variables.globals
| From: | neojoda at gmail dot com | Date: | Tue, 14 Dec 2010 20:31:28 +0000 |
| Subject: | note 101396 added to reserved.variables.globals | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174918@lists.php.net to get a copy of this message | ||
If you wants to backup a $GLOBALS variable and restore it later, you cannot do:
$tmp = $GLOBALS;
//do something that modify $GLOBALS
$GLOBALS = $tmp
because in my tests, I see that $tmp doesn't not has a copy. It seems is a copy by reference.
I found this way to do correctly:
$tmp = serialize($GLOBALS);
//do something that modify $GLOBALS
$GLOBALS = unserialize($GLOBALS);
----
Server IP: 69.147.83.197
Probable Submitter: 71.237.33.244
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.globals.php
Edit -- https://master.php.net/note/edit/101396
Del: integrated -- https://master.php.net/note/delete/101396/integrated
Del: useless -- https://master.php.net/note/delete/101396/useless
Del: bad code -- https://master.php.net/note/delete/101396/bad+code
Del: spam -- https://master.php.net/note/delete/101396/spam
Del: non-english -- https://master.php.net/note/delete/101396/non-english
Del: in docs -- https://master.php.net/note/delete/101396/in+docs
Del: other reasons-- https://master.php.net/note/delete/101396
Reject -- https://master.php.net/note/reject/101396
Search -- https://master.php.net/manage/user-notes.php