PrepAway - Latest Free Exam Questions & Answers

How would you correct it?

The following code piece should print “PHP is cool”, but unexpectedly, it just prints “cool”. How would you correct it?
<code>
echo str_replace(‘PHP is a pain.’, ‘a pain’, ‘cool’);
</code>

PrepAway - Latest Free Exam Questions & Answers

A.
str_replace(‘PHP is a pain.’, ‘cool’, ‘a pain’);

B.
str_replace(‘a pain’, ‘cool’, ‘PHP is a pain.’);

C.
str_replace(‘cool’, ‘a pain’, ‘PHP is a pain.’);

One Comment on “How would you correct it?


Leave a Reply

Your email address will not be published. Required fields are marked *