HTTP_POST_VARS not and array when used in a function?
| From: | Joseph Blythe | Date: | Wed, 18 Apr 2001 01:18:14 +0000 |
| Subject: | HTTP_POST_VARS not and array when used in a function? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-49100@lists.php.net to get a copy of this message | ||
Hey,
Why doesn't HTTP_POST_VARS work inside functions?
---somefile.php - forms action ---
function foo() {
reset($HTTP_POST_VARS);
while( list($key, $val) = each($HTTP_POST_VARS) ) {
if ( $key != "Submit" xor $key != "x" xor $key != "y" ) {
$input[$key] = $val;
}
}
return $input;
}
$input = foo();
---
I thought the above would work but it returns the following error(s):
... value passed to reset is not an array or object ...
... value passed to each is not an array or object ...
It seems that HTTP_POST_VARS does not like being called from inside functions, as the above will work if not inside the function, I thought that HTTP_POST_VARS was in the global scope (as of php 4.0.3 track-vars is always on) , so it should have no problem being called from anywhere?
Does anyone know what gives?
Regards,
Joseph