Annotation of embedaddon/php/ext/ereg/tests/ereg_replace_variation_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
11: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
12: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
13: }
14: set_error_handler('test_error_handler');
15:
16: echo "*** 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;
24: unset ($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:
75: foreach($values as $value) {
76: echo "\nArg value $value \n";
77: var_dump( ereg_replace($value, $replacement, $string) );
78: };
79:
80: echo "Done";
81: ?>
82: --EXPECTF--
83: *** Testing ereg_replace() : usage variations ***
84: Error: 8 - Undefined variable: undefined_var, %s(64)
85: Error: 8 - Undefined variable: unset_var, %s(67)
86:
87: Arg value 0
88: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
89: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
90: bool(false)
91:
92: Arg value 1
93: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
94: string(8) "original"
95:
96: Arg value 12345
97: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
98: string(8) "original"
99:
100: Arg value -2345
101: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
102: string(8) "original"
103:
104: Arg value 10.5
105: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
106: string(8) "original"
107:
108: Arg value -10.5
109: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
110: string(8) "original"
111:
112: Arg value 101234567000
113: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
114: string(8) "original"
115:
116: Arg value 1.07654321E-9
117: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
118: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
119: bool(false)
120:
121: Arg value 0.5
122: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
123: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
124: bool(false)
125:
126: Arg value Array
127: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
128: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
129: bool(false)
130:
131: Arg value Array
132: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
133: string(8) "original"
134:
135: Arg value Array
136: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
137: string(8) "original"
138:
139: Arg value Array
140: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
141: string(8) "original"
142:
143: Arg value Array
144: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
145: string(8) "original"
146:
147: Arg value
148: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
149: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
150: bool(false)
151:
152: Arg value
153: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
154: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
155: bool(false)
156:
157: Arg value 1
158: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
159: string(8) "original"
160:
161: Arg value
162: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
163: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
164: bool(false)
165:
166: Arg value 1
167: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
168: string(8) "original"
169:
170: Arg value
171: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
172: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
173: bool(false)
174:
175: Arg value
176: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
177: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
178: bool(false)
179:
180: Arg value
181: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
182: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
183: bool(false)
184: Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
185:
186: Arg value
187: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
188: Error: 8 - Object of class stdClass could not be converted to int, %s(74)
189: string(8) "original"
190:
191: Arg value
192: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
193: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
194: bool(false)
195:
196: Arg value
197: Error: 8192 - Function ereg_replace() is deprecated, %s(74)
198: Error: 2 - ereg_replace(): REG_EMPTY, %s(74)
199: bool(false)
200: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>