Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - String Functions
What will be the output of this PHP code?
$text = "PHP 7.4";
echo strlen($text);
A6
B7
C9
D8
Step-by-Step Solution
Solution:
  1. Step 1: Count all characters in "PHP 7.4"

    Characters: P, H, P, space, 7, ., 4 = 7 total characters.
  2. Step 2: strlen() returns total character count

    strlen($text) returns 7, which is printed.
  3. Final Answer:

    7 -> Option B
  4. Quick Check:

    strlen("PHP 7.4") = 7 [OK]
Quick Trick: Count spaces and punctuation as characters [OK]
Common Mistakes:
  • Ignoring spaces
  • Counting only letters and digits
  • Choosing wrong length

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes