Multiple choice technology web technology

  1. Which of the following function returns the number of characters in a string variable?

  1. count($variable)
  2. len($variable)
  3. strcount($variable)
  4. strlen($variable)
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

strlen() is the correct PHP function to count the number of characters in a string. Option A, count(), is used for counting elements in arrays, not string characters. Option B, len(), is not a PHP function (it exists in Python). Option C, strcount(), is not a standard PHP function. The naming convention 'str' prefix for string functions is common in PHP (strpos, strlen, strstr, etc.), making strlen() the memorable choice for string length.