Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q4 of 15
PHP - Arrays
What will be the output of this PHP code?
$values = [10, 20, 30, 40, 50];
echo count($values);
A4
B5
C50
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the array

    The array $values contains 5 elements: 10, 20, 30, 40, 50.
  2. Step 2: Apply count()

    count($values) returns the number of elements, which is 5.
  3. Final Answer:

    5 -> Option B
  4. Quick Check:

    Count elements, not sum or max value [OK]
Quick Trick: count() returns number of array elements [OK]
Common Mistakes:
  • Confusing count() with sum()
  • Expecting highest value instead of count
  • Assuming zero-based index count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes