Zend
200-530 · Question #3750
The following code piece should print "PHP is cool", but unexpectedly, it just prints "cool". How would you correct it? echo str_replace('PHP is a pain.', 'a pain', 'cool');
The correct answer is B. str_replace('a pain', 'cool', 'PHP is a pain.'). Explanation/Reference:
Strings & Patterns
Question
The following code piece should print "PHP is cool", but unexpectedly, it just prints "cool". How would you correct it? echo str_replace('PHP is a pain.', 'a pain', 'cool');
Options
- Astr_replace('PHP is a pain.', 'cool', 'a pain');
- Bstr_replace('a pain', 'cool', 'PHP is a pain.');
- Cstr_replace('cool', 'a pain', 'PHP is a pain.');
How the community answered
(40 responses)- A15% (6)
- B78% (31)
- C8% (3)
Explanation
Explanation/Reference:
Topics
#str_replace#argument order#string replacement#search replace
Community Discussion
No community discussion yet for this question.