Php Objective Questions with Answers for written test exams 22

Question 22
Which of the following functions is most efficient for substituting fixed patterns in

strings?

A. preg_replace()

B. str_replace()

C. str_ireplace()

D. substr_replace()
Answers 22


Answer B is correct.The PHP efficiency mantra is “do no more work than necessary.”

Both str_ireplace() and preg_replace() have more expensive (and flexible)

matching logic, so you should only use them when your problem requires it.

substr_replace() requires you to know the offsets and lengths of the substrings

you want to replace, and is not sufficient to handle the task at hand.

  







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---