Bird
0
0

What will this PHP code output?

medium📝 Predict Output Q5 of 15
PHP - Variables and Data Types
What will this PHP code output?
$var1 = 10;
$Var1 = 20;
echo $var1 + $Var1;
AError: Undefined variable
B30
C10
D20
Step-by-Step Solution
Solution:
  1. Step 1: Recognize variable case sensitivity

    $var1 and $Var1 are different variables with values 10 and 20 respectively.
  2. Step 2: Calculate the sum

    Adding 10 + 20 equals 30, which is printed.
  3. Final Answer:

    The output is 30. -> Option B
  4. Quick Check:

    Case sensitive variables add separately = D [OK]
Quick Trick: Variables with different cases are distinct in PHP [OK]
Common Mistakes:
  • Assuming variables with different cases are same
  • Expecting error for case difference
  • Ignoring case sensitivity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes