PHP 为什么 &&& 不会触发为 false?


这是因为,如果您使用 &&&,则这两个条件都必须为真。如果任何一个条件为假,则总体条件将计算为假。

PHP 代码如下 −

示例

 在线演示

<!DOCTYPE html>
<html>
<body>
<?php
   $firstCondition= "John";
   $secondCondition = "David";
   if ($firstCondition == "John" && $secondCondition == "David" && ($firstCondition == "Mike" || $firstCondition == "John")) {
      echo "The above condition is true";
   } else {
      echo "The above condition is not true";
   }
?>
</body>
</html>

输出

The above condition is true

更新日期:2020-11-20

53 次浏览

开启你的 职业生涯

完成课程获得认证

立刻开始
广告