1--TEST--
2Test sizeof() function : usage variations - all kinds of unset variables for 'var' argument
3--FILE--
4<?php
5/* Prototype  : int sizeof($mixed var[, int $mode])
6 * Description: Counts an elements in an array. If Standard PHP library is installed,
7 * it will return the properties of an object.
8 * Source code: ext/standard/basic_functions.c
9 * Alias to functions: count()
10 */
11
12echo "*** Testing sizeof() : usage variations ***\n";
13
14echo "--- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes ---\n";
15
16// class declaration
17class test
18{
19  public $member1;
20}
21
22// get an resource variable
23$fp = fopen(__FILE__, "r");
24
25// array containing different types of variables
26$values = array (
27            // int values
28  /* 1  */  0,
29            1,
30            // float values
31  /* 3  */  10.5,
32            -10.5,
33            12.34e3,
34  /* 6  */  12.34E-3,
35            // string values
36  /* 7  */  "string",
37            'string',
38            "",
39  /* 10 */  '',
40            // NULL values
41  /* 11 */  NULL,
42            null,
43            // Boolean Values
44  /* 12 */  TRUE,
45            true,
46            false,
47  /* 16 */  FALSE,
48            // array values
49  /* 17 */  array(),
50            array(1, 2, 3,4 , array(5, 6)),
51            // object variable
52  /* 19 */  new test(),
53            // resource variable
54  /* 20 */  $fp
55);
56
57// loop through the each element of the $values array for 'var' argument
58// and check the functionality of sizeof()
59$counter = 1;
60foreach($values as $value)
61{
62  echo "-- Iteration $counter --\n";
63
64  // unset the variable
65  unset($value);
66
67  // now check the size of unset variable when different modes are given
68  echo "Default Mode: ";
69  var_dump( sizeof($value) );
70  echo "\n";
71
72  echo "COUNT_NORMAL Mode: ";
73  var_dump( sizeof($value, COUNT_NORMAL) );
74  echo "\n";
75
76  echo "COUNT_RECURSIVE Mode: ";
77  var_dump( sizeof($value, COUNT_RECURSIVE) );
78  echo "\n";
79
80  $counter++;
81}
82
83fclose($fp);
84
85echo "Done";
86?>
87--EXPECTF--
88*** Testing sizeof() : usage variations ***
89--- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes ---
90-- Iteration 1 --
91Default Mode:
92Notice: Undefined variable: value in %s on line %d
93
94Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
95int(0)
96
97COUNT_NORMAL Mode:
98Notice: Undefined variable: value in %s on line %d
99
100Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
101int(0)
102
103COUNT_RECURSIVE Mode:
104Notice: Undefined variable: value in %s on line %d
105
106Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
107int(0)
108
109-- Iteration 2 --
110Default Mode:
111Notice: Undefined variable: value in %s on line %d
112
113Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
114int(0)
115
116COUNT_NORMAL Mode:
117Notice: Undefined variable: value in %s on line %d
118
119Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
120int(0)
121
122COUNT_RECURSIVE Mode:
123Notice: Undefined variable: value in %s on line %d
124
125Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
126int(0)
127
128-- Iteration 3 --
129Default Mode:
130Notice: Undefined variable: value in %s on line %d
131
132Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
133int(0)
134
135COUNT_NORMAL Mode:
136Notice: Undefined variable: value in %s on line %d
137
138Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
139int(0)
140
141COUNT_RECURSIVE Mode:
142Notice: Undefined variable: value in %s on line %d
143
144Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
145int(0)
146
147-- Iteration 4 --
148Default Mode:
149Notice: Undefined variable: value in %s on line %d
150
151Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
152int(0)
153
154COUNT_NORMAL Mode:
155Notice: Undefined variable: value in %s on line %d
156
157Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
158int(0)
159
160COUNT_RECURSIVE Mode:
161Notice: Undefined variable: value in %s on line %d
162
163Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
164int(0)
165
166-- Iteration 5 --
167Default Mode:
168Notice: Undefined variable: value in %s on line %d
169
170Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
171int(0)
172
173COUNT_NORMAL Mode:
174Notice: Undefined variable: value in %s on line %d
175
176Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
177int(0)
178
179COUNT_RECURSIVE Mode:
180Notice: Undefined variable: value in %s on line %d
181
182Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
183int(0)
184
185-- Iteration 6 --
186Default Mode:
187Notice: Undefined variable: value in %s on line %d
188
189Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
190int(0)
191
192COUNT_NORMAL Mode:
193Notice: Undefined variable: value in %s on line %d
194
195Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
196int(0)
197
198COUNT_RECURSIVE Mode:
199Notice: Undefined variable: value in %s on line %d
200
201Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
202int(0)
203
204-- Iteration 7 --
205Default Mode:
206Notice: Undefined variable: value in %s on line %d
207
208Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
209int(0)
210
211COUNT_NORMAL Mode:
212Notice: Undefined variable: value in %s on line %d
213
214Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
215int(0)
216
217COUNT_RECURSIVE Mode:
218Notice: Undefined variable: value in %s on line %d
219
220Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
221int(0)
222
223-- Iteration 8 --
224Default Mode:
225Notice: Undefined variable: value in %s on line %d
226
227Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
228int(0)
229
230COUNT_NORMAL Mode:
231Notice: Undefined variable: value in %s on line %d
232
233Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
234int(0)
235
236COUNT_RECURSIVE Mode:
237Notice: Undefined variable: value in %s on line %d
238
239Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
240int(0)
241
242-- Iteration 9 --
243Default Mode:
244Notice: Undefined variable: value in %s on line %d
245
246Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
247int(0)
248
249COUNT_NORMAL Mode:
250Notice: Undefined variable: value in %s on line %d
251
252Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
253int(0)
254
255COUNT_RECURSIVE Mode:
256Notice: Undefined variable: value in %s on line %d
257
258Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
259int(0)
260
261-- Iteration 10 --
262Default Mode:
263Notice: Undefined variable: value in %s on line %d
264
265Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
266int(0)
267
268COUNT_NORMAL Mode:
269Notice: Undefined variable: value in %s on line %d
270
271Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
272int(0)
273
274COUNT_RECURSIVE Mode:
275Notice: Undefined variable: value in %s on line %d
276
277Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
278int(0)
279
280-- Iteration 11 --
281Default Mode:
282Notice: Undefined variable: value in %s on line %d
283
284Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
285int(0)
286
287COUNT_NORMAL Mode:
288Notice: Undefined variable: value in %s on line %d
289
290Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
291int(0)
292
293COUNT_RECURSIVE Mode:
294Notice: Undefined variable: value in %s on line %d
295
296Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
297int(0)
298
299-- Iteration 12 --
300Default Mode:
301Notice: Undefined variable: value in %s on line %d
302
303Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
304int(0)
305
306COUNT_NORMAL Mode:
307Notice: Undefined variable: value in %s on line %d
308
309Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
310int(0)
311
312COUNT_RECURSIVE Mode:
313Notice: Undefined variable: value in %s on line %d
314
315Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
316int(0)
317
318-- Iteration 13 --
319Default Mode:
320Notice: Undefined variable: value in %s on line %d
321
322Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
323int(0)
324
325COUNT_NORMAL Mode:
326Notice: Undefined variable: value in %s on line %d
327
328Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
329int(0)
330
331COUNT_RECURSIVE Mode:
332Notice: Undefined variable: value in %s on line %d
333
334Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
335int(0)
336
337-- Iteration 14 --
338Default Mode:
339Notice: Undefined variable: value in %s on line %d
340
341Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
342int(0)
343
344COUNT_NORMAL Mode:
345Notice: Undefined variable: value in %s on line %d
346
347Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
348int(0)
349
350COUNT_RECURSIVE Mode:
351Notice: Undefined variable: value in %s on line %d
352
353Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
354int(0)
355
356-- Iteration 15 --
357Default Mode:
358Notice: Undefined variable: value in %s on line %d
359
360Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
361int(0)
362
363COUNT_NORMAL Mode:
364Notice: Undefined variable: value in %s on line %d
365
366Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
367int(0)
368
369COUNT_RECURSIVE Mode:
370Notice: Undefined variable: value in %s on line %d
371
372Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
373int(0)
374
375-- Iteration 16 --
376Default Mode:
377Notice: Undefined variable: value in %s on line %d
378
379Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
380int(0)
381
382COUNT_NORMAL Mode:
383Notice: Undefined variable: value in %s on line %d
384
385Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
386int(0)
387
388COUNT_RECURSIVE Mode:
389Notice: Undefined variable: value in %s on line %d
390
391Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
392int(0)
393
394-- Iteration 17 --
395Default Mode:
396Notice: Undefined variable: value in %s on line %d
397
398Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
399int(0)
400
401COUNT_NORMAL Mode:
402Notice: Undefined variable: value in %s on line %d
403
404Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
405int(0)
406
407COUNT_RECURSIVE Mode:
408Notice: Undefined variable: value in %s on line %d
409
410Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
411int(0)
412
413-- Iteration 18 --
414Default Mode:
415Notice: Undefined variable: value in %s on line %d
416
417Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
418int(0)
419
420COUNT_NORMAL Mode:
421Notice: Undefined variable: value in %s on line %d
422
423Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
424int(0)
425
426COUNT_RECURSIVE Mode:
427Notice: Undefined variable: value in %s on line %d
428
429Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
430int(0)
431
432-- Iteration 19 --
433Default Mode:
434Notice: Undefined variable: value in %s on line %d
435
436Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
437int(0)
438
439COUNT_NORMAL Mode:
440Notice: Undefined variable: value in %s on line %d
441
442Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
443int(0)
444
445COUNT_RECURSIVE Mode:
446Notice: Undefined variable: value in %s on line %d
447
448Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
449int(0)
450
451-- Iteration 20 --
452Default Mode:
453Notice: Undefined variable: value in %s on line %d
454
455Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
456int(0)
457
458COUNT_NORMAL Mode:
459Notice: Undefined variable: value in %s on line %d
460
461Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
462int(0)
463
464COUNT_RECURSIVE Mode:
465Notice: Undefined variable: value in %s on line %d
466
467Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
468int(0)
469
470Done
471