Bird
0
0

Which of the following is the correct syntax to get the length of a string stored in variable $text?

easy📝 Syntax Q12 of 15
PHP - String Functions
Which of the following is the correct syntax to get the length of a string stored in variable $text?
Astrlen($text);
Bsize($text);
Ccount($text);
Dlength($text);
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct function for string length

    In PHP, strlen() is the built-in function to get string length.
  2. Step 2: Check syntax correctness

    strlen($text); correctly calls the function with the variable.
  3. Final Answer:

    strlen($text); -> Option A
  4. Quick Check:

    Use strlen() with parentheses and variable [OK]
Quick Trick: Use strlen() with parentheses around the variable [OK]
Common Mistakes:
  • Using length() which is not a PHP function
  • Using count() which is for arrays
  • Forgetting parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes