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 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

立刻開始
廣告
© . All rights reserved.