Annotation of embedaddon/php/ext/pcre/tests/preg_replace_error1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test preg_replace() function : error - bad regular expressions
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: */
9: error_reporting(E_ALL&~E_NOTICE);
10: /*
11: * Testing how preg_replace reacts to being passed the wrong type of regex argument
12: */
13: echo "*** Testing preg_replace() : error conditions***\n";
14: $regex_array = array('abcdef', //Regex without delimeter
15: '/[a-zA-Z]', //Regex without closing delimeter
16: '[a-zA-Z]/', //Regex without opening delimeter
17: '/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
18: '[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
19: );
20: $replace = 1;
21: $subject = 'a';
22: foreach($regex_array as $regex_value) {
23: print "\nArg value is $regex_value\n";
24: var_dump(preg_replace($regex_value, $replace, $subject));
25: }
26: $regex_value = new stdclass(); //Object
27: var_dump(preg_replace($regex_value, $replace, $subject));
28: ?>
29: --EXPECTF--
30: *** Testing preg_replace() : error conditions***
31:
32: Arg value is abcdef
33:
34: Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in %spreg_replace_error1.php on line %d
35: NULL
36:
37: Arg value is /[a-zA-Z]
38:
39: Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d
40: NULL
41:
42: Arg value is [a-zA-Z]/
43:
44: Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d
45: NULL
46:
47: Arg value is /[a-zA-Z]/F
48:
49: Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d
50: NULL
51:
52: Arg value is Array
53: string(1) "a"
54:
55: Arg value is /[a-zA-Z]/
56: string(1) "1"
57:
58: Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error1.php on line %d
59:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>