nerdexam
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)
  • A
    15% (6)
  • B
    78% (31)
  • C
    8% (3)

Explanation

Explanation/Reference:

Topics

#str_replace#argument order#string replacement#search replace

Community Discussion

No community discussion yet for this question.

Full 200-530 Practice