Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - Type Handling
What will be the output of this PHP code?
$arr = [1, 2, 3];
echo gettype($arr);
Acollection
Bobject
Clist
Darray
Step-by-Step Solution
Solution:
  1. Step 1: Identify type of $arr

    $arr is an array in PHP, created with square brackets.
  2. Step 2: gettype() returns "array" for arrays

    So echo gettype($arr); outputs "array".
  3. Final Answer:

    array -> Option D
  4. Quick Check:

    gettype(array) = "array" [OK]
Quick Trick: Arrays return "array" string from gettype() [OK]
Common Mistakes:
  • Thinking arrays are objects
  • Expecting "list" or "collection"
  • Confusing with JSON types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes