Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如题:if($_POST)靠谱吗?
if($_POST)
true即使没有发布数据但使用了 HTTP POST 方法,它是否可靠?
true
是if('post' === strtolower($_SERVER['REQUEST_METHOD']))一种更可靠的方法,还是矫枉过正?
if('post' === strtolower($_SERVER['REQUEST_METHOD']))
没有为什么:
数组() == 假
因此,如果没有发布数据,则条件将变为 false。所以检查 REQUEST_METHOD。请注意,与我输入它相比,您测试它所花费的时间更少。