1--TEST-- 2Test preg_replace() function : error conditions - wrong arg types 3--FILE-- 4<?php 5/* 6* Function is implemented in ext/pcre/php_pcre.c 7*/ 8/* 9* Testing how preg_replace reacts to being passed the wrong type of replacement argument 10*/ 11$regex = '/[a-zA-Z]/'; 12$replace = array('this is a string', array('this is', 'a subarray'),); 13$subject = 'test'; 14foreach($replace as $value) { 15 try { 16 var_dump(preg_replace($regex, $value, $subject)); 17 } catch (TypeError $e) { 18 echo $e->getMessage(), "\n"; 19 } 20} 21$value = new stdclass(); //Object 22try { 23 var_dump(preg_replace($regex, $value, $subject)); 24} catch (Error $e) { 25 echo $e->getMessage(), "\n"; 26} 27?> 28--EXPECT-- 29string(64) "this is a stringthis is a stringthis is a stringthis is a string" 30preg_replace(): Argument #1 ($pattern) must be of type array when argument #2 ($replacement) is an array, string given 31preg_replace(): Argument #2 ($replacement) must be of type array|string, stdClass given 32