note 40712 added to ref.session

From: Date: Thu, 11 Mar 2004 22:42:48 +0000
Subject: note 40712 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-66691@lists.php.net to get a copy of this message
simonc att linux mail org: quote: -------------------- i.e. $_SESSION["foo"] = 5 $foo = $_SESSION["foo"]; $foo = 2; NOW $_SESSION["foo"] will equal 2. -------------------- The "interesting feature" that you discovered is probably because you have register_globals enabled. Thus, when you first set $_SESSION['foo'] it is indeed 5. Then you give $foo the value of $_SESSION['foo']. However, because register_globals is turned on, you actually assign $_SESSION['foo'] = $_SESSION['foo']. You can try this: $_SESSION['foo'] = 5; $foo = 2; //sets $_SESSION['foo'] = 2 You will find that $_SESSION['foo'] is now 2 also. Neat, huh? :) ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40712 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40712&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40712&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66691) next »