RE: [PHP] Variables don't pass... *sniff*

From: Date: Thu, 29 May 2003 09:33:16 +0000
Subject: RE: [PHP] Variables don't pass... *sniff*
Groups: php.general 
Request: Send a blank email to php-general+get-149363@lists.php.net to get a copy of this message
> -----Original Message----- > From: Wendell Brown [mailto:wbrown@arkie.net] > Sent: 28 May 2003 15:02 > > On Wed, 28 May 2003 12:46:50 +0100, David Grant wrote: > > >I would've thought that $HTTP_*_VARS will be deprecated > sometime in the > >future. It might be an idea to write your own accessor methods, e.g. > > > >function RetrieveGetParameter($parameterValue) > > Egads! Wouldn't the following be a little simpler? > > At the top of the file put..... > > if( is_array($_POST) ) > $pArray = $_POST; > else > $pArray = $HTTP_POST_VARS; > > Then access $pArray["fred"] where ever you want to? And yes, I know > this creates a second copy of the post array in local memory Only if you actually change any of the elements -- otherwise, PHP does what's called a _shallow_copy_, which doesn't actually copy all the values unless it becomes necessary. > (wouldn't > pointers be nice right about now) Well, how about references, then? (And me, personally, I'd use isset() rather than is_array().) if (isset($_POST)): $POST = &$_POST; else: $POST = &$HTTP_POST_VARS; endif; 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

« previous php.general (#149363) next »