2 /* Prototype : int sizeof($mixed var[, int $mode])
3 * Description: Counts an elements in an array. If Standard PHP library is installed,
4 * it will return the properties of an object.
5 * Source code: ext/standard/basic_functions.c
6 * Alias to functions: count()
9 echo "*** Testing sizeof() : usage variations ***\n";
11 echo "--- Testing sizeof() with different values for 'mode' argument ---\n";
12 $array1 = array(1, 2, 3, 4, array(1.0, 2.0, array()), array() );
14 // get a resource variable
15 $fp = fopen(__FILE__
, "r");
27 $mode_values = array (
30 0, // same as COUNT_NORMAL
31 1, // same as COUNT_RECURSIVE
33 /* 5 */ TRUE, // same as COUNT_RECURSIVE
34 true, // same as COUNT_RECURSIVE
35 FALSE, // same as COUNT_NORMAL
36 false, // same as COUNT_NORMAL
37 NULL, // same as COUNT_NORMAL
38 /* 10 */ null, // same as COUNT_NORMAL
53 // loop through the each element of $modes_array for 'mode' argument
54 // and check the working of sizeof()
56 for($i = 0; $i < count($mode_values); $i++
)
58 echo "-- Iteration $counter --\n";
59 $mode = $mode_values[$i];
61 var_dump( sizeof($array1, $mode) );