NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_REQUEST: Bad Form?

csnyder chsnyder at gmail.com
Fri Oct 12 17:07:52 EDT 2007


On 10/12/07, Brian D. <brian at realm3.com> wrote:
> I can't find where I read it originally, but somewhere I've been told
> or read that "using $_REQUEST is bad form." I understand that in cases
> where you want to force a $_POST request, but if you might receive
> $_GET or $_POST then isn't is better than doing if/elses?

As others have mentioned, it is harder to debug and/or more open to
confusion because it combines inputs, and that can sometimes lead to
surprising results.

It's not that you shouldn't use it, but you should be aware of the
potential consequences (POSTed values overwriting GET, COOKIE values
overwriting GET and POST) when you do.

The semantics of the get and post HTTP methods is different. Get
requests are always supposed to be "safe," not making changes to
server-side resources. There is no expectation that post requests
_must_ be unsafe, but it's kind of implied.

Based on that, I think it is good form to pick either get or post for
your interface, depending on whether a resource is being updated or
not.

-- 
Chris Snyder
http://chxo.com/



More information about the talk mailing list