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?


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to