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' arugment
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
93int(0)
94
95COUNT_NORMAL Mode:
96Notice: Undefined variable: value in %s on line %d
97int(0)
98
99COUNT_RECURSIVE Mode:
100Notice: Undefined variable: value in %s on line %d
101int(0)
102
103-- Iteration 2 --
104Default Mode:
105Notice: Undefined variable: value in %s on line %d
106int(0)
107
108COUNT_NORMAL Mode:
109Notice: Undefined variable: value in %s on line %d
110int(0)
111
112COUNT_RECURSIVE Mode:
113Notice: Undefined variable: value in %s on line %d
114int(0)
115
116-- Iteration 3 --
117Default Mode:
118Notice: Undefined variable: value in %s on line %d
119int(0)
120
121COUNT_NORMAL Mode:
122Notice: Undefined variable: value in %s on line %d
123int(0)
124
125COUNT_RECURSIVE Mode:
126Notice: Undefined variable: value in %s on line %d
127int(0)
128
129-- Iteration 4 --
130Default Mode:
131Notice: Undefined variable: value in %s on line %d
132int(0)
133
134COUNT_NORMAL Mode:
135Notice: Undefined variable: value in %s on line %d
136int(0)
137
138COUNT_RECURSIVE Mode:
139Notice: Undefined variable: value in %s on line %d
140int(0)
141
142-- Iteration 5 --
143Default Mode:
144Notice: Undefined variable: value in %s on line %d
145int(0)
146
147COUNT_NORMAL Mode:
148Notice: Undefined variable: value in %s on line %d
149int(0)
150
151COUNT_RECURSIVE Mode:
152Notice: Undefined variable: value in %s on line %d
153int(0)
154
155-- Iteration 6 --
156Default Mode:
157Notice: Undefined variable: value in %s on line %d
158int(0)
159
160COUNT_NORMAL Mode:
161Notice: Undefined variable: value in %s on line %d
162int(0)
163
164COUNT_RECURSIVE Mode:
165Notice: Undefined variable: value in %s on line %d
166int(0)
167
168-- Iteration 7 --
169Default Mode:
170Notice: Undefined variable: value in %s on line %d
171int(0)
172
173COUNT_NORMAL Mode:
174Notice: Undefined variable: value in %s on line %d
175int(0)
176
177COUNT_RECURSIVE Mode:
178Notice: Undefined variable: value in %s on line %d
179int(0)
180
181-- Iteration 8 --
182Default Mode:
183Notice: Undefined variable: value in %s on line %d
184int(0)
185
186COUNT_NORMAL Mode:
187Notice: Undefined variable: value in %s on line %d
188int(0)
189
190COUNT_RECURSIVE Mode:
191Notice: Undefined variable: value in %s on line %d
192int(0)
193
194-- Iteration 9 --
195Default Mode:
196Notice: Undefined variable: value in %s on line %d
197int(0)
198
199COUNT_NORMAL Mode:
200Notice: Undefined variable: value in %s on line %d
201int(0)
202
203COUNT_RECURSIVE Mode:
204Notice: Undefined variable: value in %s on line %d
205int(0)
206
207-- Iteration 10 --
208Default Mode:
209Notice: Undefined variable: value in %s on line %d
210int(0)
211
212COUNT_NORMAL Mode:
213Notice: Undefined variable: value in %s on line %d
214int(0)
215
216COUNT_RECURSIVE Mode:
217Notice: Undefined variable: value in %s on line %d
218int(0)
219
220-- Iteration 11 --
221Default Mode:
222Notice: Undefined variable: value in %s on line %d
223int(0)
224
225COUNT_NORMAL Mode:
226Notice: Undefined variable: value in %s on line %d
227int(0)
228
229COUNT_RECURSIVE Mode:
230Notice: Undefined variable: value in %s on line %d
231int(0)
232
233-- Iteration 12 --
234Default Mode:
235Notice: Undefined variable: value in %s on line %d
236int(0)
237
238COUNT_NORMAL Mode:
239Notice: Undefined variable: value in %s on line %d
240int(0)
241
242COUNT_RECURSIVE Mode:
243Notice: Undefined variable: value in %s on line %d
244int(0)
245
246-- Iteration 13 --
247Default Mode:
248Notice: Undefined variable: value in %s on line %d
249int(0)
250
251COUNT_NORMAL Mode:
252Notice: Undefined variable: value in %s on line %d
253int(0)
254
255COUNT_RECURSIVE Mode:
256Notice: Undefined variable: value in %s on line %d
257int(0)
258
259-- Iteration 14 --
260Default Mode:
261Notice: Undefined variable: value in %s on line %d
262int(0)
263
264COUNT_NORMAL Mode:
265Notice: Undefined variable: value in %s on line %d
266int(0)
267
268COUNT_RECURSIVE Mode:
269Notice: Undefined variable: value in %s on line %d
270int(0)
271
272-- Iteration 15 --
273Default Mode:
274Notice: Undefined variable: value in %s on line %d
275int(0)
276
277COUNT_NORMAL Mode:
278Notice: Undefined variable: value in %s on line %d
279int(0)
280
281COUNT_RECURSIVE Mode:
282Notice: Undefined variable: value in %s on line %d
283int(0)
284
285-- Iteration 16 --
286Default Mode:
287Notice: Undefined variable: value in %s on line %d
288int(0)
289
290COUNT_NORMAL Mode:
291Notice: Undefined variable: value in %s on line %d
292int(0)
293
294COUNT_RECURSIVE Mode:
295Notice: Undefined variable: value in %s on line %d
296int(0)
297
298-- Iteration 17 --
299Default Mode:
300Notice: Undefined variable: value in %s on line %d
301int(0)
302
303COUNT_NORMAL Mode:
304Notice: Undefined variable: value in %s on line %d
305int(0)
306
307COUNT_RECURSIVE Mode:
308Notice: Undefined variable: value in %s on line %d
309int(0)
310
311-- Iteration 18 --
312Default Mode:
313Notice: Undefined variable: value in %s on line %d
314int(0)
315
316COUNT_NORMAL Mode:
317Notice: Undefined variable: value in %s on line %d
318int(0)
319
320COUNT_RECURSIVE Mode:
321Notice: Undefined variable: value in %s on line %d
322int(0)
323
324-- Iteration 19 --
325Default Mode:
326Notice: Undefined variable: value in %s on line %d
327int(0)
328
329COUNT_NORMAL Mode:
330Notice: Undefined variable: value in %s on line %d
331int(0)
332
333COUNT_RECURSIVE Mode:
334Notice: Undefined variable: value in %s on line %d
335int(0)
336
337-- Iteration 20 --
338Default Mode:
339Notice: Undefined variable: value in %s on line %d
340int(0)
341
342COUNT_NORMAL Mode:
343Notice: Undefined variable: value in %s on line %d
344int(0)
345
346COUNT_RECURSIVE Mode:
347Notice: Undefined variable: value in %s on line %d
348int(0)
349
350Done
351