menu

PHP Strings


1. Which of the following functions is used to pad a string with a specified character to a certain length in PHP?

str_pad()

str_replace()

substr()

strlen()


2. Which of the following functions is used to trim whitespace from the beginning and end of a string in PHP?

strrev()

substr()

strlen()

trim()


3. Which of the following functions is used to find the position of the first occurrence of a substring in a string in PHP?

strpos()

str_replace()

strlen()

substr()


4. Which of the following functions is used to reverse a string in PHP?

strrev()

substr()

strlen()

strtolower()


5. What function is used to determine the length of a string in PHP?

strlen()

strrev()

str_replace()

substr()


6. Which of the following functions is used to check if a string contains a specific substring in PHP?

strpos()

str_replace()

strstr()

substr()


7. Which of the following functions is used to convert special characters to HTML entities in PHP?

htmlentities()

htmlspecialchars_decode()

htmlspecialchars()

str_replace()


8. Which of the following functions is used to split a string into an array of substrings in PHP?

substr()

str_replace()

explode()

implode()


9. What function is used to convert a string to all lowercase characters in PHP?

strtolower()

strtoupper()

substr()

strrev()


10. Which of the following functions is used to extract a substring from a string in PHP?

strpos()

str_replace()

substr()

strlen()