1--TEST--
2Test ereg() function : usage variations  - unexpected type arg 2
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 = '1';
20$registers = array();
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      // array data
43      array(),
44      array(0),
45      array(1),
46      array(1, 2),
47      array('color' => 'red', 'item' => 'pen'),
48
49      // null data
50      NULL,
51      null,
52
53      // boolean data
54      true,
55      false,
56      TRUE,
57      FALSE,
58
59      // empty data
60      "",
61      '',
62
63      // object data
64      new stdclass(),
65
66      // undefined data
67      $undefined_var,
68
69      // unset data
70      $unset_var,
71);
72
73// loop through each element of the array for string
74
75foreach($values as $value) {
76      echo "\nArg value $value \n";
77      var_dump( ereg($pattern, $value, $registers) );
78};
79
80echo "Done";
81?>
82--EXPECTF--
83*** Testing ereg() : usage variations ***
84Error: 8 - Undefined variable: undefined_var, %s(64)
85Error: 8 - Undefined variable: unset_var, %s(67)
86
87Arg value 0
88Error: 8192 - Function ereg() is deprecated, %s(74)
89bool(false)
90
91Arg value 1
92Error: 8192 - Function ereg() is deprecated, %s(74)
93int(1)
94
95Arg value 12345
96Error: 8192 - Function ereg() is deprecated, %s(74)
97int(1)
98
99Arg value -2345
100Error: 8192 - Function ereg() is deprecated, %s(74)
101bool(false)
102
103Arg value 10.5
104Error: 8192 - Function ereg() is deprecated, %s(74)
105int(1)
106
107Arg value -10.5
108Error: 8192 - Function ereg() is deprecated, %s(74)
109int(1)
110
111Arg value 101234567000
112Error: 8192 - Function ereg() is deprecated, %s(74)
113int(1)
114
115Arg value 1.07654321E-9
116Error: 8192 - Function ereg() is deprecated, %s(74)
117int(1)
118
119Arg value 0.5
120Error: 8192 - Function ereg() is deprecated, %s(74)
121bool(false)
122
123Arg value Array
124Error: 8192 - Function ereg() is deprecated, %s(74)
125Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74)
126NULL
127
128Arg value Array
129Error: 8192 - Function ereg() is deprecated, %s(74)
130Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74)
131NULL
132
133Arg value Array
134Error: 8192 - Function ereg() is deprecated, %s(74)
135Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74)
136NULL
137
138Arg value Array
139Error: 8192 - Function ereg() is deprecated, %s(74)
140Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74)
141NULL
142
143Arg value Array
144Error: 8192 - Function ereg() is deprecated, %s(74)
145Error: 2 - ereg() expects parameter 2 to be string, array given, %s(74)
146NULL
147
148Arg value
149Error: 8192 - Function ereg() is deprecated, %s(74)
150bool(false)
151
152Arg value
153Error: 8192 - Function ereg() is deprecated, %s(74)
154bool(false)
155
156Arg value 1
157Error: 8192 - Function ereg() is deprecated, %s(74)
158int(1)
159
160Arg value
161Error: 8192 - Function ereg() is deprecated, %s(74)
162bool(false)
163
164Arg value 1
165Error: 8192 - Function ereg() is deprecated, %s(74)
166int(1)
167
168Arg value
169Error: 8192 - Function ereg() is deprecated, %s(74)
170bool(false)
171
172Arg value
173Error: 8192 - Function ereg() is deprecated, %s(74)
174bool(false)
175
176Arg value
177Error: 8192 - Function ereg() is deprecated, %s(74)
178bool(false)
179Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
180
181Arg value
182Error: 8192 - Function ereg() is deprecated, %s(74)
183Error: 2 - ereg() expects parameter 2 to be string, object given, %s(74)
184NULL
185
186Arg value
187Error: 8192 - Function ereg() is deprecated, %s(74)
188bool(false)
189
190Arg value
191Error: 8192 - Function ereg() is deprecated, %s(74)
192bool(false)
193Done
194