Re: Variables don't pass... *sniff*
| From: | daniel at rhesusb dot dk | Date: | Wed, 28 May 2003 14:13:22 +0000 |
| Subject: | Re: Variables don't pass... *sniff* | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149246@lists.php.net to get a copy of this message | ||
I did this:
if (!empty($_POST)) {
extract($_POST);
} else {
extract($HTTP_POST_VARS);
}
And have it in an include file, "extract_post.php".
This way I can just include it and all variables are available, just like if
register_globals had been on.
Daniel.
----- Original Message -----
From: Wendell Brown
To: php-general@lists.php.net
Sent: Wednesday, May 28, 2003 4:01 PM
Subject: Re: [PHP] Variables don't pass... *sniff*
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 (wouldn't
pointers be nice right about now), but if the post array is going to be
accessed a lot, it would seem to be faster to copy it once than to call
the function over and over. :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php