Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - Type Handling
What will be the output of this PHP code?
$x = 0;
if ($x == false) {
echo 'Yes';
} else {
echo 'No';
}
A0
BNo
CError
DYes
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP loose comparison

    In PHP, 0 is considered false when compared with == operator.
  2. Step 2: Evaluate the if condition

    $x == false is true, so 'Yes' is printed.
  3. Final Answer:

    Yes -> Option D
  4. Quick Check:

    Loose comparison 0 == false is true [OK]
Quick Trick: 0 is false in loose comparisons (==) [OK]
Common Mistakes:
  • Confusing == with === strict comparison
  • Expecting 'No' because 0 is a number
  • Thinking it causes an error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes