xref: /PHP-5.3/ext/mbstring/tests/bug43994.phpt (revision 188f1abf)
1--TEST--
2Test mb_ereg() function : mb_ereg 'successfully' matching incorrectly
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
7?>
8--FILE--
9<?php
10/* Prototype  : int mb_ereg(string $pattern, string $string [, array $registers])
11 * Description: Regular expression match for multibyte string
12 * Source code: ext/mbstring/php_mbregex.c
13 */
14
15/*
16 * mb_ereg 'successfully' matching incorrectly:
17 * Bug now seems to be fixed - error message is now generated when an 'empty'
18 * pattern is supplied to mb_ereg. Similar error message to ereg().
19 */
20
21$unset_var = 10;
22unset ($unset_var);
23$inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var,
24@$unset_var);
25
26$iterator = 1;
27foreach($inputs as $input) {
28	if(@is_array($mb_regs)){
29		$mb_regs = '';
30	}
31	echo "\n-- Iteration $iterator --\n";
32	echo "Without \$regs arg:\n";
33	var_dump( mb_ereg($input, 'hello, world') );
34	echo "With \$regs arg:\n";
35	var_dump(mb_ereg($input, 'hello, world', $mb_regs));
36	var_dump($mb_regs);
37	$iterator++;
38};
39?>
40
41--EXPECTF--
42
43-- Iteration 1 --
44Without $regs arg:
45
46Warning: mb_ereg(): empty pattern in %s on line %d
47bool(false)
48With $regs arg:
49
50Warning: mb_ereg(): empty pattern in %s on line %d
51bool(false)
52NULL
53
54-- Iteration 2 --
55Without $regs arg:
56
57Warning: mb_ereg(): empty pattern in %s on line %d
58bool(false)
59With $regs arg:
60
61Warning: mb_ereg(): empty pattern in %s on line %d
62bool(false)
63NULL
64
65-- Iteration 3 --
66Without $regs arg:
67
68Warning: mb_ereg(): empty pattern in %s on line %d
69bool(false)
70With $regs arg:
71
72Warning: mb_ereg(): empty pattern in %s on line %d
73bool(false)
74NULL
75
76-- Iteration 4 --
77Without $regs arg:
78
79Warning: mb_ereg(): empty pattern in %s on line %d
80bool(false)
81With $regs arg:
82
83Warning: mb_ereg(): empty pattern in %s on line %d
84bool(false)
85NULL
86
87-- Iteration 5 --
88Without $regs arg:
89
90Warning: mb_ereg(): empty pattern in %s on line %d
91bool(false)
92With $regs arg:
93
94Warning: mb_ereg(): empty pattern in %s on line %d
95bool(false)
96NULL
97
98-- Iteration 6 --
99Without $regs arg:
100
101Warning: mb_ereg(): empty pattern in %s on line %d
102bool(false)
103With $regs arg:
104
105Warning: mb_ereg(): empty pattern in %s on line %d
106bool(false)
107NULL
108
109-- Iteration 7 --
110Without $regs arg:
111
112Warning: mb_ereg(): empty pattern in %s on line %d
113bool(false)
114With $regs arg:
115
116Warning: mb_ereg(): empty pattern in %s on line %d
117bool(false)
118NULL
119
120-- Iteration 8 --
121Without $regs arg:
122
123Warning: mb_ereg(): empty pattern in %s on line %d
124bool(false)
125With $regs arg:
126
127Warning: mb_ereg(): empty pattern in %s on line %d
128bool(false)
129NULL
130