note 42269 added to language.variables.predefined

From: Date: Mon, 10 May 2004 15:59:32 +0000
Subject: note 42269 added to language.variables.predefined
Groups: php.notes 
Request: Send a blank email to php-notes+get-69413@lists.php.net to get a copy of this message
This code needs slightly changed... function remap_globals() { global $GET_VARS, $POST_VARS, $COOKIE_VARS, $SESSION_VARS, $SERVER_VARS, $ENV_VARS; $parser_version = phpversion(); if ($parser_version <= "4.1.0") { $GET = &$GET_VARS; $POST = &$POST_VARS; $COOKIES = &$COOKIE_VARS; $SESSION = &$HTTP_SESSION_VARS; $SERVER = &$HTTP_SERVER_VARS; $ENV = &$HTTP_ENV_VARS; } if ($parser_version >= "4.1.0") { $GET = &$_GET; $POST = &$_POST; $COOKIES = &$_COOKIE; $SESSION = &$_SESSION; $SERVER = &$_SERVER; $ENV = &$_ENV; } } Note the ampersands. They ensure that the variables act _exactly_ like the superglobal components, ie: changing $SESSION will update $_SESSION and thus update the local session files. So yeah. I don't know what the PHP name for that is, but in C it's called dereferencing, and I've seen it done in function definitions in myriad people's code, but not once in a standard variable situation. Oh well. Can't be creative all the time ^_^ ---- Manual Page -- http://www.php.net/manual/en/language.variables.predefined.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42269 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42269&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42269&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69413) next »