PHP/Wordpress - 否定条件的问题
PHP/Wordpress - Problems with negating conditions
有时当我尝试 post 一个 php-snippet(使用 XYZScripts 的 XYZ PHP CODE)时,我收到以下错误:
方法未实现
POST 到 /wp-admin/admin。php 不支持。
我发现它与否定条件 e 有关。 G。在 if 条件下,例如:
((!empty($_GET['test1'])) && (!empty($_GET['test2']))) or
(!(empty($_GET['test1'])) && (empty($_GET['test2'])))
but (!empty($_GET['test1']) && !empty($_GET['test2'])) works
另一次我遇到的情况如下:
!(error_reporting() & $severity)
谁能解释一下原因?
不是答案,但太长无法发表评论。
没有什么可否定的
((!empty($_GET['test1'])) && (!empty($_GET['test2']))) or
(!(empty($_GET['test1'])) && (empty($_GET['test2'])))
从左到右阅读:
GET:test1 is not empty and GET:test2 is not empty
OR
GET:test1 is not empty and GET:test2 is empty
当然,如果只是书面或口头表达会更好:
GET:test1 is not empty
你最好让你的条件更简单、更易读。
例如。 !(empty($_GET['test1']))
应该只是 !empty($_GET['test1'])
有时当我尝试 post 一个 php-snippet(使用 XYZScripts 的 XYZ PHP CODE)时,我收到以下错误:
方法未实现 POST 到 /wp-admin/admin。php 不支持。
我发现它与否定条件 e 有关。 G。在 if 条件下,例如:
((!empty($_GET['test1'])) && (!empty($_GET['test2']))) or
(!(empty($_GET['test1'])) && (empty($_GET['test2'])))
but (!empty($_GET['test1']) && !empty($_GET['test2'])) works
另一次我遇到的情况如下:
!(error_reporting() & $severity)
谁能解释一下原因?
不是答案,但太长无法发表评论。
没有什么可否定的((!empty($_GET['test1'])) && (!empty($_GET['test2']))) or
(!(empty($_GET['test1'])) && (empty($_GET['test2'])))
从左到右阅读:
GET:test1 is not empty and GET:test2 is not empty
OR
GET:test1 is not empty and GET:test2 is empty
当然,如果只是书面或口头表达会更好:
GET:test1 is not empty
你最好让你的条件更简单、更易读。
例如。 !(empty($_GET['test1']))
应该只是 !empty($_GET['test1'])