Re: Code Advice
| From: | Jason Young | Date: | Wed, 06 Nov 2002 19:13:04 +0000 |
| Subject: | Re: Code Advice | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123050@lists.php.net to get a copy of this message | ||
Hmm..
So then can anyone tell me why its working so far? ;)
I am trying out every single function in this page in hopes to catch something, but so far I don't see any breakage - I can see there are a few ways to skin this cat.. the original code I posted DOES work.. I still may be blind to any future breakings.. that's why I posted it. Unfortunately, I'm getting responses saying that this code won't work at all - when it does.. :-/
Mike Ford wrote:
-----Original Message----- From: Kevin Stone [mailto:kevin@helpelf.com] Sent: 06 November 2002 18:50 To: php-general@lists.php.net Subject: Re: [PHP] Code Advice All I have to go by is what I see. The method was this.. <? $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key]))Mea culpa -- you're quite right, and I should read more carefully! (Well, it is 7pm and going home time....) This should, of course, be done like this: $get_allow = array(......); foreach ($get_allow as $key):$$key = $val;} ?> The array $get_allow has numerical indicies. Looping through that in the method described is going to set an integer to $key. So your first error is going to be that $_GET[0] is Undefined. Second error is going to be $$key is an invalid variable name.if (isset($_GET($key)): $$key = $_GET[$key]; endif;endforeach; Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.ukTel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211