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