1--TEST--
2Test ereg() function : usage variations  - unexpected type for arg 3
3--FILE--
4<?php
5/* Prototype  : proto int ereg(string pattern, string string [, array registers])
6 * Description: Regular expression match
7 * Source code: ext/standard/reg.c
8 * Alias to functions:
9 */
10
11function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
12	echo "Error: $err_no - $err_msg, $filename($linenum)\n";
13}
14set_error_handler('test_error_handler');
15
16echo "*** Testing ereg() : usage variations ***\n";
17
18// Initialise function arguments not being substituted (if any)
19$pattern = 'h(.*)lo!';
20$string = 'hello!';
21
22//get an unset variable
23$unset_var = 10;
24unset ($unset_var);
25
26//array of values to iterate over
27$values = array(
28
29      // int data
30      0,
31      1,
32      12345,
33      -2345,
34
35      // float data
36      10.5,
37      -10.5,
38      10.1234567e10,
39      10.7654321E-10,
40      .5,
41
42      // null data
43      NULL,
44      null,
45
46      // boolean data
47      true,
48      false,
49      TRUE,
50      FALSE,
51
52      // empty data
53      "",
54      '',
55
56      // string data
57      "string",
58      'string',
59
60      // object data
61      new stdclass(),
62
63      // undefined data
64      $undefined_var,
65
66      // unset data
67      $unset_var,
68);
69
70// loop through each element of the array for registers
71
72foreach($values as $value) {
73      echo "\nArg value $value \n";
74      var_dump( ereg($pattern, $string, $value) );
75      var_dump($value);
76};
77
78echo "Done";
79?>
80--EXPECTF--
81*** Testing ereg() : usage variations ***
82Error: 8 - Undefined variable: undefined_var, %s(61)
83Error: 8 - Undefined variable: unset_var, %s(64)
84
85Arg value 0
86Error: 8192 - Function ereg() is deprecated, %s(71)
87int(6)
88array(2) {
89  [0]=>
90  string(6) "hello!"
91  [1]=>
92  string(2) "el"
93}
94
95Arg value 1
96Error: 8192 - Function ereg() is deprecated, %s(71)
97int(6)
98array(2) {
99  [0]=>
100  string(6) "hello!"
101  [1]=>
102  string(2) "el"
103}
104
105Arg value 12345
106Error: 8192 - Function ereg() is deprecated, %s(71)
107int(6)
108array(2) {
109  [0]=>
110  string(6) "hello!"
111  [1]=>
112  string(2) "el"
113}
114
115Arg value -2345
116Error: 8192 - Function ereg() is deprecated, %s(71)
117int(6)
118array(2) {
119  [0]=>
120  string(6) "hello!"
121  [1]=>
122  string(2) "el"
123}
124
125Arg value 10.5
126Error: 8192 - Function ereg() is deprecated, %s(71)
127int(6)
128array(2) {
129  [0]=>
130  string(6) "hello!"
131  [1]=>
132  string(2) "el"
133}
134
135Arg value -10.5
136Error: 8192 - Function ereg() is deprecated, %s(71)
137int(6)
138array(2) {
139  [0]=>
140  string(6) "hello!"
141  [1]=>
142  string(2) "el"
143}
144
145Arg value 101234567000
146Error: 8192 - Function ereg() is deprecated, %s(71)
147int(6)
148array(2) {
149  [0]=>
150  string(6) "hello!"
151  [1]=>
152  string(2) "el"
153}
154
155Arg value 1.07654321E-9
156Error: 8192 - Function ereg() is deprecated, %s(71)
157int(6)
158array(2) {
159  [0]=>
160  string(6) "hello!"
161  [1]=>
162  string(2) "el"
163}
164
165Arg value 0.5
166Error: 8192 - Function ereg() is deprecated, %s(71)
167int(6)
168array(2) {
169  [0]=>
170  string(6) "hello!"
171  [1]=>
172  string(2) "el"
173}
174
175Arg value
176Error: 8192 - Function ereg() is deprecated, %s(71)
177int(6)
178array(2) {
179  [0]=>
180  string(6) "hello!"
181  [1]=>
182  string(2) "el"
183}
184
185Arg value
186Error: 8192 - Function ereg() is deprecated, %s(71)
187int(6)
188array(2) {
189  [0]=>
190  string(6) "hello!"
191  [1]=>
192  string(2) "el"
193}
194
195Arg value 1
196Error: 8192 - Function ereg() is deprecated, %s(71)
197int(6)
198array(2) {
199  [0]=>
200  string(6) "hello!"
201  [1]=>
202  string(2) "el"
203}
204
205Arg value
206Error: 8192 - Function ereg() is deprecated, %s(71)
207int(6)
208array(2) {
209  [0]=>
210  string(6) "hello!"
211  [1]=>
212  string(2) "el"
213}
214
215Arg value 1
216Error: 8192 - Function ereg() is deprecated, %s(71)
217int(6)
218array(2) {
219  [0]=>
220  string(6) "hello!"
221  [1]=>
222  string(2) "el"
223}
224
225Arg value
226Error: 8192 - Function ereg() is deprecated, %s(71)
227int(6)
228array(2) {
229  [0]=>
230  string(6) "hello!"
231  [1]=>
232  string(2) "el"
233}
234
235Arg value
236Error: 8192 - Function ereg() is deprecated, %s(71)
237int(6)
238array(2) {
239  [0]=>
240  string(6) "hello!"
241  [1]=>
242  string(2) "el"
243}
244
245Arg value
246Error: 8192 - Function ereg() is deprecated, %s(71)
247int(6)
248array(2) {
249  [0]=>
250  string(6) "hello!"
251  [1]=>
252  string(2) "el"
253}
254
255Arg value string
256Error: 8192 - Function ereg() is deprecated, %s(71)
257int(6)
258array(2) {
259  [0]=>
260  string(6) "hello!"
261  [1]=>
262  string(2) "el"
263}
264
265Arg value string
266Error: 8192 - Function ereg() is deprecated, %s(71)
267int(6)
268array(2) {
269  [0]=>
270  string(6) "hello!"
271  [1]=>
272  string(2) "el"
273}
274Error: 4096 - Object of class stdClass could not be converted to string, %s(70)
275
276Arg value
277Error: 8192 - Function ereg() is deprecated, %s(71)
278int(6)
279array(2) {
280  [0]=>
281  string(6) "hello!"
282  [1]=>
283  string(2) "el"
284}
285
286Arg value
287Error: 8192 - Function ereg() is deprecated, %s(71)
288int(6)
289array(2) {
290  [0]=>
291  string(6) "hello!"
292  [1]=>
293  string(2) "el"
294}
295
296Arg value
297Error: 8192 - Function ereg() is deprecated, %s(71)
298int(6)
299array(2) {
300  [0]=>
301  string(6) "hello!"
302  [1]=>
303  string(2) "el"
304}
305Done
306