Bird
0
0

What will be the output of the following PHP code?

medium📝 Predict Output Q13 of 15
PHP - Operators
What will be the output of the following PHP code?
$a = true;
$b = false;
if ($a && !$b) {
echo 'Yes';
} else {
echo 'No';
}
ANo
BYes
CSyntax Error
DNothing
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the NOT operator on $b

    $b is false, so !$b becomes true.
  2. Step 2: Evaluate the AND condition

    $a is true and !$b is true, so $a && !$b is true.
  3. Final Answer:

    Yes -> Option B
  4. Quick Check:

    true AND true = true [OK]
Quick Trick: NOT flips false to true, AND needs both true [OK]
Common Mistakes:
  • Ignoring the NOT operator effect
  • Assuming false && true is true
  • Confusing output strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes