เนื่องจากถ้าคุณใช้ &&ทั้งสองเงื่อนไขจะต้องเป็นจริง หากเงื่อนไขใดกลายเป็นเท็จ เงื่อนไขโดยรวมจะถูกประเมินเป็นเท็จ
รหัส 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