Bird
0
0

What will be the output of the following PHP code?

medium📝 Predict Output Q4 of 15
PHP - Type Handling
What will be the output of the following PHP code?
$var = null;
echo isset($var) ? 'Yes' : 'No';
ANo
BYes
CError
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Understand isset() with null

    isset() returns false if variable is null.
  2. Step 2: Evaluate ternary expression

    Since isset($var) is false, ternary returns 'No'.
  3. Final Answer:

    No -> Option A
  4. Quick Check:

    isset(null) = false [OK]
Quick Trick: isset() returns false for null variables [OK]
Common Mistakes:
  • Expecting 'Yes' for null
  • Confusing isset() with empty()
  • Thinking null prints as string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes