note 29266 deleted from language.variables.variable by danbrown
| From: | danbrown@php.net | Date: | Wed, 24 Jun 2009 16:58:45 +0000 |
| Subject: | note 29266 deleted from language.variables.variable by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157409@lists.php.net to get a copy of this message | ||
Note Submitter: Dave
----
[Editor's Note]
If you truly want to extract the variables from super globals instead of looping over the array use
extract(); or turn register globals on via an .htaccess file so it is enabled only for the script(s)
that depend on it.
[End Note]
A lot of the php code out there relies on register_globals being set to "on" in the
php.ini -- which may not be an option for some developers. It seems that the following function
would attempt to overcome that issue for later versions of php. I haven't tried it out yet, as
I have no need for it right now -- and it may pose some of the same issues as if you had
register_globals set to "on" -- but here it is, anyway.
function getRequestVariables()
{
foreach ($_POST as $postKey => $postValue)
{
global $$postKey;
$$postKey = trim (stripslashes ($postValue));
}
foreach ($_GET as $getKey => $getValue)
{
global $$getKey;
if (empty($$getKey))
{
$$getKey = trim (stripslashes ($getValue));
}
}
}