Multiple choice technology web technology

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

The strlen() function in PHP returns the number of characters in a string variable. This is the standard PHP string length function that counts all characters including spaces and special characters. The count() function in PHP counts elements in an array, not characters in a string. len() is used in some other languages like Python but is not a PHP function. strcount() is not a valid PHP function.