Strings & Regular Expressions - PHP Questions and Answers
This is the questions and answers section on "PHP Strings & Regular Expressions" with explanation for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand.
How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.
Answer: Option B
The functions are preg_filter(), preg_grep(), preg_match(), preg_match_all(), preg_quote(), preg_replace(), preg_replace_callback(), and preg_split().
Say we have two compare two strings which of the following function/functions can you use?
- A. (i) and (ii)
- B. (iii) and (iv)
- C. None of the mentioned
- D. All of the mentioned
Answer: Option D
All of the functions mentioned above can be used to compare strings in some or the other way.
Which one of the following functions will convert a string to all uppercase?
- A. strtoupper()
- B. uppercase()
- C. str_uppercase()
- D. struppercase()
Answer: Option A
Its prototype follows string
What will be the output of the following
$title = "O'malley wins the heavyweight championship!";
- A. O’Malley Wins The Heavyweight Championship!
- B. O’malley Wins The Heavyweight Championship!
- C. O’Malley wins the heavyweight championship!
- D. o’malley wins the heavyweight championship!
Answer: Option D
The ucwords() function capitalizes the first letter of each word in a string. Its prototype follows:string ucwords(string str)
What will be the output of the following PHP code?
echo str_pad("Salad", 5)." is good.";
- A. SaladSaladSaladSaladSalad is good
- B. is good SaladSaladSaladSaladSalad
- C. is good Salad
- D. Salad is good
Answer: Option D
The str_pad() function pads a string with a specified number of characters.
Free Questions and Answers, Online Test, Mock Test - Study Online
Allindiaexams.in is a one stop destination for students, job seekers and exam aspirants. Here, you will find almost every resource for online study and online exam preparation including aptitude questions and answers with solution, reasoning questions, GK questions and answers, Placement papers, Verbal ability questions and answers, engineering questions (ECE, CSE, EEE, IT, Civil, Mechanical, Aeronautical etc.), Various interview questions and answers, Free Online Test, Mock Test, Online Quiz.
With the right online education resources, students can not only study online, but can even appear for Online Practice Tests to test their skills online. Free Online Quiz and test series are available for all the topics including Aptitude, Reasoning, GK and others.
There are two different sections for Free Online Practice Tests and Online Test. In the Online study section, free online quiz and sample tests are available for Aptitude, Reasoning, GK and all other study courses. Students can study and can appear for free tests online. In the Exam preparation section, free study material is available for all the leading competitive exams, entrance exams and recruitment exams in India. Different exam categories under exam preparation section include IT company online test, startup company written exams, automobile company online test questions and answers, Government jobs, Medical, Engineering and Management exams, Defence Exams, etc.