Re: HTTP_POST_VARS not and array when used in a function?
| From: | Rasmus Lerdorf | Date: | Wed, 18 Apr 2001 01:26:59 +0000 |
| Subject: | Re: HTTP_POST_VARS not and array when used in a function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49101@lists.php.net to get a copy of this message | ||
> 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?
It is a normal global variable. Like all other global variables you need
to declare the fact that you want the global variable inside a function.
Simply put: global $HTTP_POST_VARS; at the top of your function and it
will work just fine.
Read the section on variable scope in the PHP documentation.
-Rasmus