Bird
0
0

What is the output of this PHP code?

medium📝 Predict Output Q4 of 15
PHP - Variables and Data Types
What is the output of this PHP code?
$x = '10';
$y = 5;
$z = $x + $y;
echo gettype($z);
Astring
Bdouble
Cinteger
Dboolean
Step-by-Step Solution
Solution:
  1. Step 1: Analyze addition of string and integer

    PHP converts string '10' to integer 10 for addition.
  2. Step 2: Determine result type

    Adding integer 10 and 5 results in integer 15, so type is integer.
  3. Final Answer:

    integer -> Option C
  4. Quick Check:

    Adding string number + int = int result [OK]
Quick Trick: PHP converts numeric strings to numbers in math operations [OK]
Common Mistakes:
  • Expecting string type after addition
  • Confusing with float/double type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes