0

I have never used $_REQUEST and unlike most other things that I have never used - and done some research on - I have failed to understand the point of $_REQUEST. I have done some googling and while every site I find explains that $_REQUEST combines the variables stored in $_GET, $_POST, and $_COOKIE, they do not explain its purpose.

I am a mostly autodidact programmer, so I have a tremendous respect for the fact that I do not know what I do not know, but I just cannot see the point of the $_REQUEST variable. If I have a form, I will most likely use POST to send the data, so why not use $_POST to collect the data on the other end? I reason in the same way about GET and COOKIE. Besides, $_GET, $_POST and $_COOKIE are all shorter than $_REQUEST so require less typing anyway…

Could someone please let me know if I am missing something here?

mdv
  • 39
  • 7
  • As with many other things in PHP: somebody thought it was a good idea at some point because it seemed convenient but it actually turns out to be a security flaw and/or not a good idea after all… – deceze May 08 '20 at 15:00
  • 1
    Does this answer your question? [What's the difference between $\_POST, $\_GET, and $\_REQUEST?](https://stackoverflow.com/questions/42942559/whats-the-difference-between-post-get-and-request) or https://stackoverflow.com/questions/2142497/whats-wrong-with-using-request or https://stackoverflow.com/questions/29195602/request-in-php or https://stackoverflow.com/questions/368329/why-should-i-use-get-and-post-instead-of-request – j08691 May 08 '20 at 15:00
  • @John Note that none of these *really* answer the question: why was `$_REQUEST` introduced at all, what was the creator's thinking behind it, especially when the common consensus is that it should hardly be used. – deceze May 08 '20 at 15:08
  • @j08691 - no, not really – mdv May 08 '20 at 15:09
  • 1
    @deceze I guess the next question would that question be on-topic here? – John Conde May 08 '20 at 15:10
  • @John Borderline, I'd say. It's somewhat [tag:language-lawyer]-ish. – deceze May 08 '20 at 15:12
  • 1
    PHP was created 25 years ago as an HTML template engine. As it evolved to become a full-fledged language and the WWW grew mature, some of the original features proved inadequate (and often a security risk). `$_REQUEST` does not really come from the early days but it's nonetheless an remnant of those times, kept mostly for backwards compatibility. – Álvaro González May 08 '20 at 15:36

0 Answers0