PHP String MCQs

PHP String MCQs : This section focuses on "String" in PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. In how many ways we can create strings in PHP?

A. 1
B. 2
C. 3
D. 4

View Answer

2. Which type of string can processes special characters inside quotes?

A. single quote string
B. double quote string
C. Both A and B
D. None of the above

View Answer

3. Which of the following is not a Built-in String functions in php?

A. strlen()
B. str_replace()
C. strpos()
D. strreverse()

View Answer

4. Why trim() function is used in php?

A. to remove whitespaces
B. to remove lowercase alphabet
C. to remove uppercase alphabet
D. to remove underscore

View Answer

5. Which of the following is the output of the below code?

echo strpos("Hello letsfindcourse!", "lets"), " \n"; 

A. 4
B. 5
C. 6
D. 7

View Answer

6. Which of the following is the output of the below code?

var_dump(strpos("Hello letsfindcourse!", "course")); 

A. int(13)
B. char(14)
C. int(14)
D. int(15)

View Answer

7. Which is true about var_dump() function?

A. var_dump() loops infinitely
B. var_dump() cuts off loop afetr getting same element two times
C. var_dump() cuts off loop after getting the same element three times
D. var_dump() cuts off loop after getting the same element five times

View Answer

8. The ________ function compares the two strings s1 and s2, ignoring the case of the characters.

A. strtolower()
B. toLowerCase()
C. strcasecmp()
D. lc()

View Answer

9. Returns a string arguments with trilling blank space removed, is a behavior of

A. starts( ) function
B. chop( ) function
C. rtrim( ) function
D. lc()

View Answer

10. What is the output of the following php code?

    $username = "letsfindcourse";
    if (preg_match("([^a-z])",$username))
        echo "Name must be all lowercase!";
        echo "Name is all lowercase!";

A. Error
B. No Output
C. Name must be all lowercase!
D. Name is all lowercase!

View Answer

Also check :


* You must be logged in to add comment.