Jump to content

$_POST and $_GET or $_REQUEST.


lszanto

Do you use $_REQUEST, or the individual variables?  

38 members have voted

  1. 1. Do you use $_REQUEST, or the individual variables?

    • $_REQUEST
      4
    • Individual variables
      34


Recommended Posts

When writing scripts do you prefrer to use $_REQUEST so that you can pick up both post and get or do you use the individual $_GET and $_POST depending on how you sent the variables, I personally just use $_POST or $_GET but I wanted to here what everybody else thinks.
Link to comment
https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/
Share on other sites

I try to use $_REQUEST when I can remember to use it, but I've gotten in the habit of using the individual variables. The framework we use at work handles all the server-client communications, too, so I don't actually have to deal with them.

Just a side note: $_REQUEST contains $_POST, $_GET, $_FILES, and $_COOKIE.
[quote author=Daniel0 link=topic=121453.msg500114#msg500114 date=1168296913]
[code]$input = array_merge($_POST,$_GET);[/code] ;)
[/quote]
It might sound dumb but does that mean you can do $input['varname'] to retrieve the variables send?
you do need to be careful though. IMO, $_POST and $_GET are seperate for a reason - so that you get 100% control over what should be read from where.

Daniel's example does what $_REQUEST does, but I dont like the idea that someone could come along and drop something in the URL ($_GET) that should be submitted via a form ($_POST).

Also from a debugging point of view, as i mentioned before, at least if your look at $_POST and $_GET in your code, you think "ahh, that's coming from the form and that's coming from the URL" whereas with $_REQUEST or the above example, you're kinda stuck.
I never have used request before, it's always been post, get, cookie, session.

I also agree with the comments made my redbullmarky on this one, I think it makes them easier to debug, and if I came into a program, and saw request, It would take an extra 5-10 minutes getting oriented, instead of one with post/get where I know what is going on first thing.
[quote author=redbullmarky link=topic=121453.msg499656#msg499656 date=1168252101]
$_POST and $_GET too. aside from the security, it makes it easier from a debugging point of view as I know exactly where i'm extracting the variables from.
[/quote]

This is the reason I do it :)
They're similar, but not the same thing. register_globals is much more serious in that you can over-ride an internal variable simply by putting one in the URL or POST data with the same name and the contents you'd like it to have. $_REQUEST just means that different input sources can over-ride other input sources, not internal variables.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.