Complete the code to check if both conditions are true using the AND operator.
<?php $age = 20; $hasID = true; if ($age >= 18 [1] $hasID) { echo "Access granted."; } else { echo "Access denied."; } ?>
The && operator checks if both conditions are true.
Complete the code to check if at least one condition is true using the OR operator.
<?php $isWeekend = false; $isHoliday = true; if ($isWeekend [1] $isHoliday) { echo "You can relax today."; } else { echo "You have to work."; } ?>
The || operator returns true if at least one condition is true.
Fix the error in the code to correctly negate the condition using the NOT operator.
<?php $isRaining = false; if ([1]$isRaining) { echo "Take an umbrella."; } else { echo "No umbrella needed."; } ?>
The ! operator negates a boolean value in PHP.
Fill in the blank to create a condition that is true only if exactly one of the two variables is true.
<?php $hasTicket = true; $hasInvitation = false; if ($hasTicket [1] $hasInvitation) { echo "Entry allowed."; } else { echo "Entry denied."; } ?>
The xor operator returns true only if exactly one operand is true.
Fill all three blanks to create a complex condition that checks if a user is an adult and either has a membership or a guest pass.
<?php $age = 22; $hasMembership = false; $hasGuestPass = true; if ($age >= [1] [3] ($hasMembership [2] $hasGuestPass)) { echo "Access granted."; } else { echo "Access denied."; } ?>
The code checks if age is at least 18, and if the user has either membership or guest pass. The || operator is used inside parentheses, and && connects the age check with the membership/guest pass check.