Lines Matching refs:count

2 Test count() function
7 /* Prototype: int count ( mixed $var [, int $mode] );
11 echo "*** Testing basic functionality of count() function ***\n";
14 print "COUNT_NORMAL: should be 0, is ".count($arr, COUNT_NORMAL)."\n";
15 print "COUNT_RECURSIVE: should be 0, is ".count($arr, COUNT_RECURSIVE)."\n";
19 print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n";
20 print "COUNT_RECURSIVE: should be 8, is ".count($arr, COUNT_RECURSIVE)."\n";
24 print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n";
25 print "COUNT_RECURSIVE: should be 6, is ".count($arr, COUNT_RECURSIVE)."\n";
28 print "COUNT_NORMAL: should be 1, is ".count("string", COUNT_NORMAL)."\n";
29 print "COUNT_RECURSIVE: should be 1, is ".count("string", COUNT_RECURSIVE)."\n";
32 print "COUNT_NORMAL: should be 1, is ".count("string")."\n";
33 print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n";
38 print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n";
39 print "COUNT_RECURSIVE: should be 13, is ".count($arr, COUNT_RECURSIVE)."\n";
41 echo "\n*** Testing possible variations of count() function on arrays ***";
60 print "COUNT_NORMAL is ".count($count_value, COUNT_NORMAL)."\n";
61 print "COUNT_RECURSIVE is ".count($count_value, COUNT_RECURSIVE)."\n";
66 /* Testing count() by passing constant with no second argument */
67 print "\n-- Testing count() on constants with no second argument --\n";
68 print "COUNT_NORMAL: should be 1, is ".count(100)."\n";
69 print "COUNT_NORMAL: should be 1, is ".count(-23.45)."\n";
71 print "\n-- Testing count() on NULL and Unset variables --\n";
72 print "COUNT_NORMAL: should be 0, is ".count(NULL)."\n";
73 print "COUNT_NORMAL: should be 1, is ".count("")."\n";
74 print "COUNT_NORMAL: should be 0, is ".@count($a)."\n";
77 print "\n-- Testing count() on an empty sub-array --\n";
79 print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n";
80 print "COUNT_RECURSIVE: should be 5, is ".count($arr, COUNT_RECURSIVE)."\n";
82 echo "\n-- Testing count() on objects with Countable interface --\n";
88 public function count() {
94 print "COUNT_NORMAL: should be 3, is ".count($obj)."\n";
97 echo "\n-- Testing count() on resource type --\n";
103 var_dump(count($arr_resource));
105 echo "\n-- Testing count() on arrays containing references --\n";
111 for( $i =0; $i < count( $mode_arr ); $i++) {
112 echo "For mode '$mode_arr[$i]' count is => ";
113 var_dump(count($arr, $mode_arr[$i]));
118 var_dump( count() ); // No. of args = 0
119 var_dump( count(array(), COUNT_NORMAL, 100) ); // No. of args > expected
122 var_dump( count("string", ABCD) );
123 var_dump( count(100, "string") );
124 var_dump( count(array(), "") );
133 *** Testing basic functionality of count() function ***
136 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
139 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
149 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
152 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
156 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
163 *** Testing possible variations of count() function on arrays ***
196 -- Testing count() on constants with no second argument --
198 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
201 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
204 -- Testing count() on NULL and Unset variables --
206 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
209 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
213 -- Testing count() on an empty sub-array --
217 -- Testing count() on objects with Countable interface --
220 -- Testing count() on resource type --
223 -- Testing count() on arrays containing references --
224 For mode '0' count is => int(3)
225 For mode '1' count is => int(9)
226 For mode '0' count is => int(3)
227 For mode '1' count is => int(9)
228 For mode '-1' count is => int(3)
229 For mode '-1.45' count is => int(3)
230 For mode '2' count is => int(3)
231 For mode '1' count is => int(9)
232 For mode '' count is => int(3)
233 For mode '' count is => int(3)
236 Warning: count() expects at least 1 parameter, 0 given in %s on line %d
239 Warning: count() expects at most 2 parameters, 3 given in %s on line %d
244 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d
247 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d
250 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d