RE: [PHP] Register Globals

From: Date: Mon, 21 Jul 2003 13:01:38 +0000
Subject: RE: [PHP] Register Globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-156056@lists.php.net to get a copy of this message
OK, sorry, I tried to help... and finaly I learn (I didn't know extract...) -----Message d'origine----- De : Ford, Mike [LSS] [mailto:M.Ford@lmu.ac.uk] Envoyé : lundi 21 juillet 2003 14:35 À : 'stfmoreau'; Daryl Meese; php-general@lists.php.net Objet : RE: [PHP] Register Globals > -----Original Message----- > From: stfmoreau [mailto:stfmoreau@yahoo.fr] > Sent: 21 July 2003 13:23 > > include this code in your header file : > // _GET > if (isset($_GET)) > while (list($key, $val) = each($_GET)) > { > eval ("$".$key." = '".$val."';"); > } Whoa! Nasty and inefficient!! I can understand if you decide initially to use a brute-force drop-in replacement for register_globals, and leave modifying the rest of your code until later, but really: (i) Better: // _GET if (isset($_GET)) foreach ($_GET as $key=>$val) { $$key = $val; } (ii) Even better: // _GET if (isset($_GET)) extract($_GET); 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.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#156056) next »