extract() and symbol tables
| From: | jacob at keystreams dot com | Date: | Fri, 23 Aug 2002 03:42:10 +0000 |
| Subject: | extract() and symbol tables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-113713@lists.php.net to get a copy of this message | ||
I wrote this function:
function tug_extract_url_variables() {
global $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? 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
Please help,
Jacob