1--TEST--
2Test ereg_replace() function : usage variations - unexpected type arg 1
3--FILE--
4<?php
5/* Prototype  : proto string ereg_replace(string pattern, string replacement, string string)
6 * Description: Replace regular expression
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_replace() : usage variations ***\n";
17
18// Initialise function arguments not being substituted (if any)
19$replacement = 'new';
20$string = 'original';
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 pattern
74
75foreach($values as $value) {
76      echo "\nArg value $value \n";
77      var_dump( ereg_replace($value, $replacement, $string) );
78};
79
80echo "Done";
81?>
82--EXPECTF--
83*** Testing ereg_replace() : 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_replace() is deprecated, %s(74)
89Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
90bool(false)
91
92Arg value 1
93Error: 8192 - Function ereg_replace() is deprecated, %s(74)
94string(8) "original"
95
96Arg value 12345
97Error: 8192 - Function ereg_replace() is deprecated, %s(74)
98string(8) "original"
99
100Arg value -2345
101Error: 8192 - Function ereg_replace() is deprecated, %s(74)
102string(8) "original"
103
104Arg value 10.5
105Error: 8192 - Function ereg_replace() is deprecated, %s(74)
106string(8) "original"
107
108Arg value -10.5
109Error: 8192 - Function ereg_replace() is deprecated, %s(74)
110string(8) "original"
111
112Arg value 101234567000
113Error: 8192 - Function ereg_replace() is deprecated, %s(74)
114string(8) "original"
115
116Arg value 1.07654321E-9
117Error: 8192 - Function ereg_replace() is deprecated, %s(74)
118Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
119bool(false)
120
121Arg value 0.5
122Error: 8192 - Function ereg_replace() is deprecated, %s(74)
123Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
124bool(false)
125Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d)
126
127Arg value Array
128Error: 8192 - Function ereg_replace() is deprecated, %s(74)
129Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
130bool(false)
131Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d)
132
133Arg value Array
134Error: 8192 - Function ereg_replace() is deprecated, %s(74)
135string(8) "original"
136Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d)
137
138Arg value Array
139Error: 8192 - Function ereg_replace() is deprecated, %s(74)
140string(8) "original"
141Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d)
142
143Arg value Array
144Error: 8192 - Function ereg_replace() is deprecated, %s(74)
145string(8) "original"
146Error: 8 - Array to string conversion, %sereg_replace_variation_001.php(%d)
147
148Arg value Array
149Error: 8192 - Function ereg_replace() is deprecated, %s(74)
150string(8) "original"
151
152Arg value
153Error: 8192 - Function ereg_replace() is deprecated, %s(74)
154Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
155bool(false)
156
157Arg value
158Error: 8192 - Function ereg_replace() is deprecated, %s(74)
159Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
160bool(false)
161
162Arg value 1
163Error: 8192 - Function ereg_replace() is deprecated, %s(74)
164string(8) "original"
165
166Arg value
167Error: 8192 - Function ereg_replace() is deprecated, %s(74)
168Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
169bool(false)
170
171Arg value 1
172Error: 8192 - Function ereg_replace() is deprecated, %s(74)
173string(8) "original"
174
175Arg value
176Error: 8192 - Function ereg_replace() is deprecated, %s(74)
177Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
178bool(false)
179
180Arg value
181Error: 8192 - Function ereg_replace() is deprecated, %s(74)
182Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
183bool(false)
184
185Arg value
186Error: 8192 - Function ereg_replace() is deprecated, %s(74)
187Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
188bool(false)
189Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
190
191Arg value
192Error: 8192 - Function ereg_replace() is deprecated, %s(74)
193Error: 8 - Object of class stdClass could not be converted to int, %s(74)
194string(8) "original"
195
196Arg value
197Error: 8192 - Function ereg_replace() is deprecated, %s(74)
198Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
199bool(false)
200
201Arg value
202Error: 8192 - Function ereg_replace() is deprecated, %s(74)
203Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
204bool(false)
205Done
206