PHP Questions and Answers – String – Part 1
This collection of PHP Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “String”.
1. A sequence of characters that is processed as a unit is called ______
A Arrays
B Functions
C Methods
D Strings
2. How many approaches you can use to create a string in PHP?
A 1
B 2
C 3
D 4
3. Which kind of string can treats special characters inside quotes?
A Single quote string
B Double quote string
C Both A and B
D None of the above
4. Which is not a Built-in function for string in PHP?
A strpos()
B strreverse()
C str_replace()
D strlen()
5. What’s the use of trim() function in PHP?
A to remove underscore
B to remove uppercase alphabet
C to remove lowercase alphabet
D to remove whitespaces
6. What is the result of the following PHP code?
<?php echo strpos("Welcome to StackHowTo!", "to"), " \n"; ?>
A 7
B 6
C 8
D 20
7. If you want to compare two strings which of the following function can be used?
A strcspn()
B strspn()
C strcasecmp()
D strcmp()
8. Which of the following function used to convert a string to uppercase?
A uppercase()
B str_uppercase()
C strtoupper()
D struppercase()
9. Which of the following functions can be used to concatenate array elements to a single string?
A explode()
B implode()
C concat()
D concatenate()
10. What is the result of the following PHP code?
<?php $url = "adm[email protected]"; echo ltrim(strstr($url, "@"),"@"); ?>
A admin
B stackhowto.com
D @stackhowto.com