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)
125
126Arg value Array
127Error: 8192 - Function ereg_replace() is deprecated, %s(74)
128Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
129bool(false)
130
131Arg value Array
132Error: 8192 - Function ereg_replace() is deprecated, %s(74)
133string(8) "original"
134
135Arg value Array
136Error: 8192 - Function ereg_replace() is deprecated, %s(74)
137string(8) "original"
138
139Arg value Array
140Error: 8192 - Function ereg_replace() is deprecated, %s(74)
141string(8) "original"
142
143Arg value Array
144Error: 8192 - Function ereg_replace() is deprecated, %s(74)
145string(8) "original"
146
147Arg value
148Error: 8192 - Function ereg_replace() is deprecated, %s(74)
149Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
150bool(false)
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 1
158Error: 8192 - Function ereg_replace() is deprecated, %s(74)
159string(8) "original"
160
161Arg value
162Error: 8192 - Function ereg_replace() is deprecated, %s(74)
163Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
164bool(false)
165
166Arg value 1
167Error: 8192 - Function ereg_replace() is deprecated, %s(74)
168string(8) "original"
169
170Arg value
171Error: 8192 - Function ereg_replace() is deprecated, %s(74)
172Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
173bool(false)
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)
184Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
185
186Arg value
187Error: 8192 - Function ereg_replace() is deprecated, %s(74)
188Error: 8 - Object of class stdClass could not be converted to int, %s(74)
189string(8) "original"
190
191Arg value
192Error: 8192 - Function ereg_replace() is deprecated, %s(74)
193Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
194bool(false)
195
196Arg value
197Error: 8192 - Function ereg_replace() is deprecated, %s(74)
198Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
199bool(false)
200Done
201