Re: Code Advice
| From: | Kevin Stone | Date: | Wed, 06 Nov 2002 18:32:26 +0000 |
| Subject: | Re: Code Advice | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123037@lists.php.net to get a copy of this message | ||
The method that you have described below is going to produce a numerical Key
which is going to result in several errors.
-Kevin
----- Original Message -----
From: "Jason Young" <jason1@erols.com>
To: <php-general@lists.php.net>
Sent: Wednesday, November 06, 2002 10:52 AM
Subject: [PHP] Code Advice
> 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>