Recall & Review
beginner Click to reveal answer
What PHP function is used to find the length of a string?
The
strlen() function returns the number of characters in a string.beginner Click to reveal answer
How does
strlen() count characters in a string?strlen() counts all characters including spaces, punctuation, and special characters.beginner Click to reveal answer
What will
strlen('Hello World') return?It returns
11 because there are 11 characters including the space.intermediate Click to reveal answer
How can you count how many times a specific character appears in a string in PHP?
Use the
substr_count() function to count occurrences of a substring or character.beginner Click to reveal answer
What does
substr_count('banana', 'a') return?It returns
3 because the letter 'a' appears three times in 'banana'.Which PHP function returns the length of a string?
✗ Incorrect
strlen() is the correct function to get string length.What will
strlen('Hi!') return?✗ Incorrect
The string 'Hi!' has 3 characters: H, i, and !.
Which function counts how many times a substring appears in a string?
✗ Incorrect
substr_count() counts occurrences of a substring.What does
substr_count('apple', 'p') return?✗ Incorrect
The letter 'p' appears twice in 'apple'.
Does
strlen() count spaces in a string?✗ Incorrect
strlen() counts all characters including spaces.Explain how to find the length of a string in PHP and what characters are counted.
Think about the function that returns the number of characters.
You got /3 concepts.
Describe how to count how many times a specific letter appears in a string using PHP.
There is a function that counts substrings inside strings.
You got /3 concepts.
