How do I negate this if/else comparison to just if? [closed]

会有一股神秘感。 提交于 2019-11-28 02:03:52

问题


I'm trying to set the class hidden, unless two factors are met. Currently, I'm using the code below:

<?php 
if (isset($_POST['prerequisite']) && $form == "CheckingIn")
{

}
else
{
    echo "hidden";
}
?>

How can I fix this to just be an if statement instead of an if/else?


回答1:


Negate the expression; use the "NOT" logical operator:

if (!(isset($_POST['prerequisite']) && $form == "CheckingIn")) { echo "hidden"; }

(notice the ! symbol)

Read more here: http://php.net/manual/en/language.operators.logical.php



来源:https://stackoverflow.com/questions/18247639/how-do-i-negate-this-if-else-comparison-to-just-if

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!