Bird
0
0

What will be the output of the following PHP code?

medium📝 Predict Output Q13 of 15
PHP - Variables and Data Types
What will be the output of the following PHP code?
$Var = 10;
$var = 20;
echo $Var + $var;
A20
B30
C10
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable case sensitivity in PHP

    PHP variable names are case-sensitive, so $Var and $var are different variables.
  2. Step 2: Calculate the sum of both variables

    $Var is 10 and $var is 20, so their sum is 30.
  3. Final Answer:

    30 -> Option B
  4. Quick Check:

    Case-sensitive variables sum correctly [OK]
Quick Trick: PHP variables are case-sensitive; $Var and $var differ [OK]
Common Mistakes:
  • Assuming variables with different cases are the same
  • Expecting a syntax error due to case difference
  • Ignoring case sensitivity in variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes