Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which one of the following functions finds the last occurrence of a string, returning its numerical position?(a) strlastpos()(b) strpos()(c) strlast()(d) strrpos()This question was posed to me in a job interview.This intriguing question comes from Strings and Regular Expressions topic in chapter Strings and Regular Expressions of PHP

Answer»

The CORRECT ANSWER is (d) strrpos()

BEST EXPLANATION: NONE.

2.

Which one of the following functions can be used to concatenate array elements to form a single delimited string?(a) explode()(b) implode()(c) concat()(d) concatenate()I had been asked this question in an interview for internship.Enquiry is from Strings and Regular Expressions topic in chapter Strings and Regular Expressions of PHP

Answer»

Correct OPTION is (B) IMPLODE()

EXPLANATION: None.

3.

Which one of the following functions will convert a string to all uppercase?(a) strtoupper()(b) uppercase()(c) str_uppercase()(d) struppercase()The question was asked during an interview for a job.My doubt stems from Strings and Regular Expressions topic in portion Strings and Regular Expressions of PHP

Answer» CORRECT option is (a) strtoupper()

Best EXPLANATION: Its prototype follows STRING strtoupper(string STR).
4.

How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.(a) 7(b) 8(c) 9(d) 10This question was addressed to me in unit test.My doubt is from Strings and Regular Expressions topic in section Strings and Regular Expressions of PHP

Answer»

The CORRECT CHOICE is (b) 8

The EXPLANATION is: The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().

5.

POSIX stands for ____________(a) Portable Operating System Interface for Unix(b) Portable Operating System Interface for Linux(c) Portative Operating System Interface for Unix(d) Portative Operating System Interface for LinuxThis question was posed to me in an online interview.This intriguing question originated from Strings and Regular Expressions topic in chapter Strings and Regular Expressions of PHP

Answer» RIGHT option is (a) PORTABLE OPERATING System Interface for Unix

The best explanation: NONE.
6.

POSIX implementation was deprecated in which version of PHP?(a) PHP 4(b) PHP 5(c) PHP 5.2(d) PHP 5.3I had been asked this question in an online quiz.My doubt is from Strings and Regular Expressions topic in division Strings and Regular Expressions of PHP

Answer» CORRECT OPTION is (d) PHP 5.3

For EXPLANATION: NONE.
7.

How many functions does PHP offer for searching strings using POSIX style regular expression?(a) 7(b) 8(c) 9(d) 10I have been asked this question in an online interview.My query is from Strings and Regular Expressions in portion Strings and Regular Expressions of PHP

Answer»

The correct OPTION is (a) 7

The EXPLANATION is: EREG(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and sql_regcase() are the functions offered.

8.

[:alpha:] can also be specified as ________(a) [A-Za-z0-9](b) [A-za-z](c) [A-z](d) [a-z]I have been asked this question in an interview for job.This question is from Strings and Regular Expressions in division Strings and Regular Expressions of PHP

Answer»

The correct OPTION is (b) [A-za-z]

The EXPLANATION is: [:alpha:] is nothing but LOWERCASE and uppercase alphabetical CHARACTERS.

9.

Which one of the following regular expression matches any string containing zero or one p?(a) p+(b) p*(c) P?(d) p#I got this question by my school principal while I was bunking the class.I would like to ask this question from Strings and Regular Expressions in division Strings and Regular Expressions of PHP

Answer»

Right choice is (C) P?

The EXPLANATION: NONE.