1--TEST--
2Test sizeof() function : basic functionality - for scalar types
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
7 *              installed, it will return the properties of an object.
8 * Source code: ext/standard/basic_functions.c
9 * Alias to functions: count()
10 */
11
12/* Testing the sizeof() for some of the scalar types(integer, float) values
13 * in default, COUNT_NORMAL and COUNT_RECURSIVE modes.
14 */
15
16echo "*** Testing sizeof() : basic functionality ***\n";
17
18$intval = 10;
19$floatval = 10.5;
20$stringval = "String";
21
22echo "-- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n";
23echo "default mode: ";
24var_dump( sizeof($intval) );
25echo "\n";
26echo "COUNT_NORMAL mode: ";
27var_dump( sizeof($intval, COUNT_NORMAL) );
28echo "\n";
29echo "COUNT_RECURSIVE mode: ";
30var_dump( sizeof($intval, COUNT_RECURSIVE) );
31echo "\n";
32
33echo "-- Testing sizeof() for float  type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n";
34echo "default mode: ";
35var_dump( sizeof($floatval) );
36echo "\n";
37echo "COUNT_NORMAL mode: ";
38var_dump( sizeof($floatval, COUNT_NORMAL) );
39echo "\n";
40echo "COUNT_RECURSIVE mode: ";
41var_dump( sizeof($floatval, COUNT_RECURSIVE) );
42
43echo "Done";
44?>
45--EXPECTF--
46*** Testing sizeof() : basic functionality ***
47-- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --
48default mode:
49Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
50int(1)
51
52COUNT_NORMAL mode:
53Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
54int(1)
55
56COUNT_RECURSIVE mode:
57Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
58int(1)
59
60-- Testing sizeof() for float  type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --
61default mode:
62Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
63int(1)
64
65COUNT_NORMAL mode:
66Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
67int(1)
68
69COUNT_RECURSIVE mode:
70Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d
71int(1)
72Done
73