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