Code Advice

From: Date: Wed, 06 Nov 2002 17:52:54 +0000
Subject: Code Advice
Groups: php.general 
Request: Send a blank email to php-general+get-123031@lists.php.net to get a copy of this message
I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... "if (isset($_GET['var'])) $var = $_GET['var']" .. lines on top of each page.. does this code look feasable to you? ----- $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key]))
    $$key = $val;
} ----- It SEEMS to work so far, I just don't want to throw this into a production environment if something's all screwy, so I figure I'll get a few hundred pairs of eyes.. I'm sure someone else probably thought of such a thing, I was just tired of having a page of 'if $_GET''s everywhere, and its scalable with just adding a word to the array, instead of two new lines. Any potential bugs? --Jason

« previous php.general (#123031) next »