import zend pcre tests
[hiphop-php.git] / hphp / test / zend / good / ext-pcre / preg_replace_callback_error.php
blob9fcaa10a3ca8c5e22d18a8cee6447073185308de
1 <?php
2 /*
3 * proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
4 * Function is implemented in ext/pcre/php_pcre.c
5 */
6 echo "***Testing preg_replace_callback() : error conditions***\n";
7 //Zero arguments
8 echo "\n-- Testing preg_replace_callback() function with Zero arguments --\n";
9 var_dump(preg_replace_callback());
10 //Test preg_replace_callback() with one more than the expected number of arguments
11 echo "\n-- Testing preg_replace_callback() function with more than expected no. of arguments --\n";
12 $replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
13 function integer_word($matches) {
14 global $replacement;
15 return $replacement[$matches[0]];
17 $regex = '/\d/';
18 $subject = 'there are 7 words in this sentence.';
19 $limit = 10;
20 $extra_arg = 10;
21 var_dump(preg_replace_callback($regex, 'integer_word', $subject, $limit, $count, $extra_arg));
22 //Testing preg_replace_callback() with one less than the expected number of arguments
23 echo "\n-- Testing preg_replace_callback() function with less than expected no. of arguments --\n";
24 $regex = '/\d/';
25 var_dump(preg_replace_callback($regex, 'integer word'));
26 echo "Done";