Which of the following function returns the number of characters in a string variable?
-
count($variable)
-
len($variable)
-
strcount($variable)
-
strlen($variable)
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.