문제

As per the title: is if($_POST) reliable?

Is it reliably true even if no data was posted but the HTTP POST method was used?

Is if('post' === strtolower($_SERVER['REQUEST_METHOD'])) a more reliable method, or is it overkill?

도움이 되었습니까?

해결책

No.. because:

array() == false

So if no data is posted, the condition will turn out false. So check against the REQUEST_METHOD. Note that it would have taken you less time to test this, than for me to type this out.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top