Annotation of embedaddon/php/ext/ereg/tests/split_variation_003.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test split() function : usage variations - unexpected type for arg 3
3: --FILE--
4: <?php
5: /* Prototype : proto array split(string pattern, string string [, int limit])
6: * Description: Split string into array by 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: if (error_reporting() != 0) {
13: // report non-silenced errors
14: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
15: }
16: }
17: set_error_handler('test_error_handler');
18: echo "*** Testing split() : usage variations ***\n";
19:
20: // Initialise function arguments not being substituted (if any)
21: $pattern = b'[[:space:]]';
22: $string = '1 2 3 4 5';
23:
24: //get an unset variable
25: $unset_var = 10;
26: unset ($unset_var);
27:
28: //array of values to iterate over
29: $values = array(
30:
31: // float data
32: 10.5,
33: -10.5,
34: 10.7654321E-10,
35: .5,
36:
37: // array data
38: array(),
39: array(0),
40: array(1),
41: array(1, 2),
42: array('color' => 'red', 'item' => 'pen'),
43:
44: // null data
45: NULL,
46: null,
47:
48: // boolean data
49: true,
50: false,
51: TRUE,
52: FALSE,
53:
54: // empty data
55: "",
56: '',
57:
58: // string data
59: "string",
60: 'string',
61:
62: // object data
63: new stdclass(),
64:
65: // undefined data
66: @$undefined_var,
67:
68: // unset data
69: @$unset_var,
70: );
71:
72: // loop through each element of the array for limit
73:
74: foreach($values as $value) {
75: echo "\nArg value $value \n";
76: var_dump( split($pattern, $string, $value) );
77: };
78:
79: echo "Done";
80: ?>
81: --EXPECTF--
82: *** Testing split() : usage variations ***
83:
84: Arg value 10.5
85: Error: 8192 - Function split() is deprecated, %s(73)
86: array(5) {
87: [0]=>
88: string(1) "1"
89: [1]=>
90: string(1) "2"
91: [2]=>
92: string(1) "3"
93: [3]=>
94: string(1) "4"
95: [4]=>
96: string(1) "5"
97: }
98:
99: Arg value -10.5
100: Error: 8192 - Function split() is deprecated, %s(73)
101: array(1) {
102: [0]=>
103: string(9) "1 2 3 4 5"
104: }
105:
106: Arg value 1.07654321E-9
107: Error: 8192 - Function split() is deprecated, %s(73)
108: array(1) {
109: [0]=>
110: string(9) "1 2 3 4 5"
111: }
112:
113: Arg value 0.5
114: Error: 8192 - Function split() is deprecated, %s(73)
115: array(1) {
116: [0]=>
117: string(9) "1 2 3 4 5"
118: }
119:
120: Arg value Array
121: Error: 8192 - Function split() is deprecated, %s(73)
122: Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
123: NULL
124:
125: Arg value Array
126: Error: 8192 - Function split() is deprecated, %s(73)
127: Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
128: NULL
129:
130: Arg value Array
131: Error: 8192 - Function split() is deprecated, %s(73)
132: Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
133: NULL
134:
135: Arg value Array
136: Error: 8192 - Function split() is deprecated, %s(73)
137: Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
138: NULL
139:
140: Arg value Array
141: Error: 8192 - Function split() is deprecated, %s(73)
142: Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
143: NULL
144:
145: Arg value
146: Error: 8192 - Function split() is deprecated, %s(73)
147: array(1) {
148: [0]=>
149: string(9) "1 2 3 4 5"
150: }
151:
152: Arg value
153: Error: 8192 - Function split() is deprecated, %s(73)
154: array(1) {
155: [0]=>
156: string(9) "1 2 3 4 5"
157: }
158:
159: Arg value 1
160: Error: 8192 - Function split() is deprecated, %s(73)
161: array(1) {
162: [0]=>
163: string(9) "1 2 3 4 5"
164: }
165:
166: Arg value
167: Error: 8192 - Function split() is deprecated, %s(73)
168: array(1) {
169: [0]=>
170: string(9) "1 2 3 4 5"
171: }
172:
173: Arg value 1
174: Error: 8192 - Function split() is deprecated, %s(73)
175: array(1) {
176: [0]=>
177: string(9) "1 2 3 4 5"
178: }
179:
180: Arg value
181: Error: 8192 - Function split() is deprecated, %s(73)
182: array(1) {
183: [0]=>
184: string(9) "1 2 3 4 5"
185: }
186:
187: Arg value
188: Error: 8192 - Function split() is deprecated, %s(73)
189: Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
190: NULL
191:
192: Arg value
193: Error: 8192 - Function split() is deprecated, %s(73)
194: Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
195: NULL
196:
197: Arg value string
198: Error: 8192 - Function split() is deprecated, %s(73)
199: Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
200: NULL
201:
202: Arg value string
203: Error: 8192 - Function split() is deprecated, %s(73)
204: Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
205: NULL
206: Error: 4096 - Object of class stdClass could not be converted to string, %s(72)
207:
208: Arg value
209: Error: 8192 - Function split() is deprecated, %s(73)
210: Error: 2 - split() expects parameter 3 to be long, object given, %s(73)
211: NULL
212:
213: Arg value
214: Error: 8192 - Function split() is deprecated, %s(73)
215: array(1) {
216: [0]=>
217: string(9) "1 2 3 4 5"
218: }
219:
220: Arg value
221: Error: 8192 - Function split() is deprecated, %s(73)
222: array(1) {
223: [0]=>
224: string(9) "1 2 3 4 5"
225: }
226: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>