menu

PHP Strings


1. Which of the following functions is used to replace a substring with another string in PHP?

strpos()

str_replace()

substr()

strtolower()


2. Which of the following functions is used to compare two strings in PHP?

strcmp()

str_replace()

strlen()

substr()


3. Which of the following functions is used to concatenate two or more strings in PHP?

strlen()

substr()

str_replace()

strcat()


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

strlen()

strrev()

str_replace()

substr()


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

strpos()

str_replace()

strstr()

substr()


6. Which of the following functions is used to join the elements of an array into a string in PHP?

substr()

str_replace()

explode()

implode()


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

strrev()

substr()

strlen()

trim()


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

str_split()

explode()

implode()

substr()


9. 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()


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

strrev()

substr()

strlen()

strtolower()