Bird
0
0

What is the output of the following PHP code?

medium📝 Predict Output Q13 of 15
PHP - Variables and Data Types
What is the output of the following PHP code?
$a = '10 apples';
$b = 10;
var_dump($a == $b);
Abool(true)
Bstring('10 apples')
Cint(10)
Dbool(false)
Step-by-Step Solution
Solution:
  1. Step 1: Understand comparison with == operator

    Using == triggers type juggling, so PHP converts the string to a number.
  2. Step 2: Convert string to number and compare

    '10 apples' converts to 10, so 10 == 10 is true.
  3. Final Answer:

    bool(true) -> Option A
  4. Quick Check:

    '10 apples' == 10 is true due to type juggling [OK]
Quick Trick: == converts strings to numbers if possible [OK]
Common Mistakes:
  • Assuming string stays string in comparison
  • Expecting false because of extra text
  • Confusing var_dump output with print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes