$_REQUEST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

$_REQUEST

Post 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.
Last edited by Mightywayne on Wed Aug 08, 2007 4:19 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_REQUEST

Post 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).
Post Reply