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