note 101396 deleted from reserved.variables.globals by danbrown
| From: | danbrown@php.net | Date: | Tue, 14 Dec 2010 20:36:12 +0000 |
| Subject: | note 101396 deleted from reserved.variables.globals by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174919@lists.php.net to get a copy of this message | ||
Note Submitter: neojoda at gmail dot com
----
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);