|
Posted by chris_fieldhouse@hotmail.com on 01/08/07 19:16
Andy Hassall wrote:
> On 8 Jan 2007 10:35:38 -0800, "chris_fieldhouse@hotmail.com"
> <chris_fieldhouse@hotmail.com> wrote:
>
> >I am migrating a web page originally written for PHP4 to PHP5,
> >everything is going well, except for one problem which has me stumped!
> >
> >Part of my PHP script lists all the values passed to it in the URL and
> >read using the $_GET.
> >
> >breaking it down into a simple function to demonstrate the problem.
> >
> >if(sizeof($_GET)) {
> > while(list($key, $val) = each($HTTP_GET_VARS)) {
> > echo $key . " : " . $val" . "<br>";
> > }
> >}
> >
> >In PHP4, this lists out all the parameters passed to this page in the
> >URL.
> >But in PHP5, nothing. The loop is not entered.
> >
> >Checking the "sizeof($_GET)" shows that the values are there, and I can
> >access them using $_GET['<whatever>'] if I know the name of the value,
> >but I want to be able to show the parameters, both key and value,
> >passed in the URL.
> >
> >Can someone help?
> >Is the $HTTP_GET_VARS not supportted in PHP5, or am I using it wrong?
> >Any advice would be appreciated.
>
> It's optional; do you have the "register_long_arrays" option turned on? I
> believe it's off by default in PHP5, so only the superglobals ($_GET etc.) will
> hold values, and not the old $HTTP_GET_VARS globals.
>
> It's a bit weird to use both $_GET and $HTTP_GET_VARS at the same time - you
> probably ought to just use $_GET throughout - after all, they contain the same
> data.
>
> --
> Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
> http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Thank you Andy.
another banging head on desk moment.
changing it to while(list($key, $val) = each($_GET))
works perfect.
what is scary is the number of online examples floating around that
merrily mixes using $_GET and $HTTP_GET_VARS in the same section of
code!
Thanks again!
Chris.
Navigation:
[Reply to this message]
|