Some guy called one of my Snipplr submissions "crap" because I used
if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of
Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue?
Well, they don't do the same thing, really.
$_SERVER['REQUEST_METHOD'] contains the request method (surprise).
$_POST contains any post data.
It's possible for a POST request to contain no POST data.
I check the request method — I actually never thought about testing the
$_POST array. I check the required post fields, though. So an empty post request would give the user a lot of error messages - which makes sense to me.
if ($_SERVER['REQUEST_METHOD'] == 'POST') is the correct way, you can send a post request without any post data.