note 16759 added to function.unset

From: Date: Mon, 12 Nov 2001 16:24:03 +0000
Subject: note 16759 added to function.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-20758@lists.php.net to get a copy of this message
Had a spot of bother with the idea that HTTP_GET_VARS['whatever'] operates as one reference when you've got the global form variables turned on, (see me care about looking up what it's called). Of course I had quite forgotten about referenced variables because the way I code things what would be the point? So, I coded this... foreach ($HTTP_GET_VARS as $key => $value) { $HTTP_GET_VARS[$key] = null; } and of course it did not work, because the script, which authenticates users, (I know about sessions, I'm just not using them), still read the variable being referenced, which wasn't what I thought was logical. There is more than one way of thinking about things however, and after a bit of head banging, I wrote this... foreach ($HTTP_GET_VARS as $key => $value) { $HTTP_GET_VARS[$key] = null; $$key = null; } which works and is rather elegant in my opinion, as all programming should be. -- http://www.php.net/manual/en/function.unset.php http://master.php.net/manage/user-notes.php?action=edit+16759 http://master.php.net/manage/user-notes.php?action=delete+16759 http://master.php.net/manage/user-notes.php?action=reject+16759

« previous php.notes (#20758) next »