Page 1 of 1

$_REQUEST

Posted: Wed Aug 08, 2007 3:43 pm
by Mightywayne
So I've just been innocently using $_POST and $_GET when I needed to. POST for forms, GET for URLs. Peachy.

So then all of a sudden, one of my scripts doesn't work. ONLY ONE, though. And I used a $_GET in it. This is the only script that does this.

I change it to REQUEST, bang. Works perfectly.

So I go to look it up in W3, and I get this:

"The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods."

But what's odd is, there's no down sides. I look at the PHP manual, can't find a down side. (it was also a tad opaque)

So my question - are there any down sides, or should I change every post and get I have, to request?

Edit: Thanks, guys.

Posted: Wed Aug 08, 2007 3:47 pm
by feyd
The fact that it's the merger of several super-globals is a downside. That the merging is affected by configuration settings is another downside.

If you need something like it, build it yourself by merging the super-globals you wish to use together in the manner you wish them to be merged.

Posted: Wed Aug 08, 2007 3:59 pm
by volka
If you and your script do not care about the source (get/post/cookie) and you do not expect a conflict of parameter names (e.g. name=xyz via get and name=abc via post) there's no real downside.

Re: $_REQUEST

Posted: Wed Aug 08, 2007 4:40 pm
by superdezign
Using $_REQUEST gives you a similar effect as using register_globals, though not AS unpredictable. The overlapping may easily cause difficulty, especially since you are using it for get requests and they have the lowest precedence by default (GPCS).