1--TEST--
2Test preg_replace() function : error conditions - wrong arg types
3--FILE--
4<?php
5/*
6* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
7* Function is implemented in ext/pcre/php_pcre.c
8*/
9error_reporting(E_ALL&~E_NOTICE);
10/*
11* Testing how preg_replace reacts to being passed the wrong type of replacement argument
12*/
13echo "*** Testing preg_replace() : error conditions ***\n";
14$regex = '/[a-zA-Z]/';
15$replace = array('this is a string', array('this is', 'a subarray'),);
16$subject = 'test';
17foreach($replace as $value) {
18    print "\nArg value is: $value\n";
19    var_dump(preg_replace($regex, $value, $subject));
20}
21$value = new stdclass(); //Object
22var_dump(preg_replace($regex, $value, $subject));
23echo "Done";
24?>
25--EXPECTF--
26*** Testing preg_replace() : error conditions ***
27
28Arg value is: this is a string
29string(64) "this is a stringthis is a stringthis is a stringthis is a string"
30
31Arg value is: Array
32
33Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d
34bool(false)
35
36Recoverable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d
37