Re: extract() and symbol tables
| From: | Jason Wong | Date: | Fri, 23 Aug 2002 04:59:00 +0000 |
| Subject: | Re: extract() and symbol tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-113714@lists.php.net to get a copy of this message | ||
On Friday 23 August 2002 11:42, jacob@keystreams.com wrote:
> I wrote this function:
>
> function tug_extract_url_variables() {
> global $HTTP_SERVER_VARS;
You're using $_GET & $_POST which implies that you can use $_SERVER instead of
$HTTP_SERVER_VARS.
> if (($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'GET') &&
> (!empty($_GET))) { return extract($_GET, EXTR_PREFIX_ALL, "formvar");
> } else if (($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST') &&
> (!empty
> ($_POST))) {
> return extract($_POST, EXTR_PREFIX_ALL, "formvar");
> } else {
> return false;
> }
> }
>
>
> Calling this function of course only returns the number of variables found
> or false on failure and I understand why it doesn't make the variables
> accessible outside the scope of the function. I am wondering, is there any
> way I can make all these variables available outside the local function's
> scope?
You can use import_request_variables() to stuff them into the _global_ scope.
> Mainly, I want to call it within a method of a class and make the
> variables available only in that method and since I want to use it in
> several different methods I want to make the code reusable
What you can do is have your tug_extract_url_variables() return a single array
which contains all the form variables.
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
"May the forces of evil become confused on the way to your house."
-- George Carlin
*/