If found this question $_POST vs. $_SERVER['REQUEST_METHOD'] == 'POST' and people seems to prefer check $_SERVER['REQUEST_METHOD'] == 'POST'
rather than check $_POST
or isset($_POST)
.
(Already, i don't understand why people check isset($_POST)
, while it is always set)
But what if we check !empty($_POST)
instead all of this ?
I mean, the $_POST
superglobale is always defined on a page as an empty array
, so just checking if it's not empty mean thats a form with the post method
has been submitted, am I wrong ? If it's not empty, we can check each fields we want inside.
I don't get why we need to add an additional step by checking
$_SERVER['REQUEST_METHOD'] == 'POST'
(Also, triple "=" wouldn't be better ?)
I've searched but found nothing about it. And if i find nothing, it probably means that i'm saying nonsense ^^.
Can someone tell me if I am wrong ?