note 50027 added to reserved.variables

From: Date: Wed, 16 Feb 2005 00:35:20 +0000
Subject: note 50027 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-85091@lists.php.net to get a copy of this message
I've come across a bit of a nasty with globals vs superglobals. I've got some scripts that try and be friendly to older versions of php as well as new ones. So I've got this code <?php if ( version_compare( phpversion(), "4.1.0", "<") ) { $_SERVER = &$HTTP_SERVER_VARS; $_SESSION = &$HTTP_SESSION_VARS; } ?> so that I can use $_SESSION everywhere. I think this is probably not the best solution but it was what I used. However in trying to debug a problem I found a couple of functions with <?php global $_SESSION; ?> in. The globals are there to cover the case where $_SESSION is a reference and not a superglobal. This appears to work under 4.3.8 and not work under 4.3.4 where 'work' is defined as just being a redundant declaration that doesn't break anything. In 4.3.4 it imports the global definition of $_SESSION but any modifications are lost when you leave the scope. Anyone one know what it's supposed to do? ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50027 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50027&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50027&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50027&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50027&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50027&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50027&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85091) next »