On Fri, 2009-08-28 at 09:33 -0700, Ben Dunlap wrote:
> I was surprised when no one recommended this:
> if ($_SERVER['REQUEST_METHOD'] == 'POST')
> So now I'm wondering if there's a pitfall to this method that I'm not
> aware of...
Well, as far as I'm aware $_SERVER isn't reliable from server to server.
That said, I've never had a problem using it.
I probably wouldn't use this however, as it does only check for the
existence of POST data. Sometimes I'll trigger the same PHP script from
both POST and GET. For example, a search form would use POST in the
initial form, and then if it was paginated, the links forwards and
backwards through the results would be GET (like Google) I usually just
tend to use the $_REQUEST array instead of $_POST or $_GET. You get the
benefit of being able to work with both arrays (as well as $_SESSION and
$_COOKIE) without any drawbacks.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php