1--TEST--
2Test preg_replace_callback() function : error
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_callback reacts to being passed the wrong type of regex argument
12*/
13echo "*** Testing preg_replace_callback() : error conditions ***\n";
14$regex_array = array('abcdef', //Regex without delimiters
15'/[a-zA-Z]', //Regex without closing delimiter
16'[a-zA-Z]/', //Regex without opening delimiter
17'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
18'[A-Z]', '[0-9]'), '/[a-zA-Z]/'); //Regex string
19$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
20function integer_word($matches) {
21    global $replacement;
22    return $replacement[$matches[0]];
23}
24$subject = 'number 1.';
25foreach($regex_array as $regex_value) {
26    print "\nArg value is $regex_value\n";
27    var_dump(preg_replace_callback($regex_value, 'integer_word', $subject));
28}
29?>
30===Done===
31--EXPECTF--
32*** Testing preg_replace_callback() : error conditions ***
33
34Arg value is abcdef
35
36Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in %s on line %d
37NULL
38
39Arg value is /[a-zA-Z]
40
41Warning: preg_replace_callback(): No ending delimiter '/' found in %s on line %d
42NULL
43
44Arg value is [a-zA-Z]/
45
46Warning: preg_replace_callback(): Unknown modifier '/' in %s on line %d
47NULL
48
49Arg value is /[a-zA-Z]/F
50
51Warning: preg_replace_callback(): Unknown modifier 'F' in %s on line %d
52NULL
53
54Arg value is Array
55string(9) "number 1."
56
57Arg value is /[a-zA-Z]/
58string(3) " 1."
59===Done===
60