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 ***
153 *** Testing possible variations of count() function on arrays ***
186 -- Testing count() on constants with no second argument --
190 -- Testing count() on NULL and Unset variables --
195 -- Testing count() on an empty sub-array --
199 -- Testing count() on objects with Countable interface --
202 -- Testing count() on resource type --
205 -- Testing count() on arrays containing references --
206 For mode '0' count is => int(3)
207 For mode '1' count is => int(9)
208 For mode '0' count is => int(3)
209 For mode '1' count is => int(9)
210 For mode '-1' count is => int(3)
211 For mode '-1.45' count is => int(3)
212 For mode '2' count is => int(3)
213 For mode '1' count is => int(9)
214 For mode '' count is => int(3)
215 For mode '' count is => int(3)
218 Warning: count() expects at least 1 parameter, 0 given in %s on line %d
221 Warning: count() expects at most 2 parameters, 3 given in %s on line %d
226 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d
229 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d
232 Warning: count() expects parameter 2 to be integer, %s given in %s on line %d