1--TEST--
2Test sizeof() function : basic functionality - for non-scalar type(array)
3--FILE--
4<?php
5/* Testing the sizeof() for non-scalar type(array) value
6 * in default, COUNT_NORMAL and COUNT_RECURSIVE modes.
7 * Sizeof() has been tested for simple integer, string,
8 * indexed and mixed arrays.
9 */
10
11echo "*** Testing sizeof() : basic functionality ***\n";
12
13$int_array = array(1, 2, 3, 4);
14$string_array = array("Saffron", "White", "Green");
15$indexed_array = array("Aggression" => "Saffron", "Peace" => "White", "Growth" => "Green");
16$mixed_array = array(1, 2, "Aggression" => "Saffron", 10 => "Ten", "Ten" => 10);
17
18echo "-- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
19echo "default mode: ";
20var_dump( sizeof($int_array) );
21echo "\n";
22echo "COUNT_NORMAL mode: ";
23var_dump( sizeof($int_array, COUNT_NORMAL) );
24echo "\n";
25echo "COUNT_RECURSIVE mode: ";
26var_dump( sizeof($int_array, COUNT_RECURSIVE) );
27echo "\n";
28
29echo "-- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
30echo "default mode: ";
31var_dump( sizeof($string_array) );
32echo "\n";
33echo "COUNT_NORMAL mode: ";
34var_dump( sizeof($string_array, COUNT_NORMAL) );
35echo "\n";
36echo "COUNT_RECURSIVE mode: ";
37var_dump( sizeof($string_array, COUNT_RECURSIVE) );
38echo "\n";
39
40echo "-- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
41echo "default mode: ";
42var_dump( sizeof($indexed_array) );
43echo "\n";
44echo "COUNT_NORMAL mode: ";
45var_dump( sizeof($indexed_array, COUNT_NORMAL) );
46echo "\n";
47echo "COUNT_RECURSIVE mode: ";
48var_dump( sizeof($indexed_array, COUNT_RECURSIVE) );
49echo "\n";
50
51echo "-- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
52echo "default mode: ";
53var_dump( sizeof($mixed_array) );
54echo "\n";
55echo "COUNT_NORMAL mode: ";
56var_dump( sizeof($mixed_array, COUNT_NORMAL) );
57echo "\n";
58echo "COUNT_RECURSIVE mode: ";
59var_dump( sizeof($mixed_array, COUNT_RECURSIVE) );
60
61echo "Done";
62?>
63--EXPECT--
64*** Testing sizeof() : basic functionality ***
65-- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
66default mode: int(4)
67
68COUNT_NORMAL mode: int(4)
69
70COUNT_RECURSIVE mode: int(4)
71
72-- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
73default mode: int(3)
74
75COUNT_NORMAL mode: int(3)
76
77COUNT_RECURSIVE mode: int(3)
78
79-- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
80default mode: int(3)
81
82COUNT_NORMAL mode: int(3)
83
84COUNT_RECURSIVE mode: int(3)
85
86-- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
87default mode: int(5)
88
89COUNT_NORMAL mode: int(5)
90
91COUNT_RECURSIVE mode: int(5)
92Done
93