1--TEST-- 2Test preg_replace() function : error - incorrect number of parameters 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*/ 9echo "*** Testing preg_replace() : error conditions ***\n"; 10//Zero arguments 11echo "\n-- Testing preg_replace() function with zero arguments --\n"; 12var_dump(preg_replace()); 13//Test preg_replace() with one more than the expected number of arguments 14echo "\n-- Testing preg_replace() function with more than expected no. of arguments --\n"; 15$regex = '/\w/'; 16$replace = '1'; 17$subject = 'string_val'; 18$limit = 10; 19$extra_arg = 10; 20var_dump(preg_replace($regex, $replace, $subject, $limit, $count, $extra_arg)); 21//Testing preg_replace() with one less than the expected number of arguments 22echo "\n-- Testing preg_replace() function with less than expected no. of arguments --\n"; 23$regex = '/\w/'; 24$replace = '1'; 25var_dump(preg_replace($regex, $replace)); 26echo "Done" 27?> 28--EXPECTF-- 29*** Testing preg_replace() : error conditions *** 30 31-- Testing preg_replace() function with zero arguments -- 32 33Warning: preg_replace() expects at least 3 parameters, 0 given in %s on line %d 34NULL 35 36-- Testing preg_replace() function with more than expected no. of arguments -- 37 38Warning: preg_replace() expects at most 5 parameters, 6 given in %s on line %d 39NULL 40 41-- Testing preg_replace() function with less than expected no. of arguments -- 42 43Warning: preg_replace() expects at least 3 parameters, 2 given in %s on line %d 44NULL 45Done 46