Lines Matching refs:count

2 Test count() function
5 /* Prototype: int count ( mixed $var [, int $mode] );
9 echo "*** Testing basic functionality of count() function ***\n";
12 print "COUNT_NORMAL: should be 0, is ".count($arr, COUNT_NORMAL)."\n";
13 print "COUNT_RECURSIVE: should be 0, is ".count($arr, COUNT_RECURSIVE)."\n";
17 print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n";
18 print "COUNT_RECURSIVE: should be 8, is ".count($arr, COUNT_RECURSIVE)."\n";
22 print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n";
23 print "COUNT_RECURSIVE: should be 6, is ".count($arr, COUNT_RECURSIVE)."\n";
26 print "COUNT_NORMAL: should be 1, is ".count("string", COUNT_NORMAL)."\n";
27 print "COUNT_RECURSIVE: should be 1, is ".count("string", COUNT_RECURSIVE)."\n";
30 print "COUNT_NORMAL: should be 1, is ".count("string")."\n";
31 print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n";
36 print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n";
37 print "COUNT_RECURSIVE: should be 13, is ".count($arr, COUNT_RECURSIVE)."\n";
39 echo "\n*** Testing possible variations of count() function on arrays ***";
58 print "COUNT_NORMAL is ".count($count_value, COUNT_NORMAL)."\n";
59 print "COUNT_RECURSIVE is ".count($count_value, COUNT_RECURSIVE)."\n";
64 /* Testing count() by passing constant with no second argument */
65 print "\n-- Testing count() on constants with no second argument --\n";
66 print "COUNT_NORMAL: should be 1, is ".count(100)."\n";
67 print "COUNT_NORMAL: should be 1, is ".count(-23.45)."\n";
69 print "\n-- Testing count() on NULL and Unset variables --\n";
70 print "COUNT_NORMAL: should be 0, is ".count(NULL)."\n";
71 print "COUNT_NORMAL: should be 1, is ".count("")."\n";
72 print "COUNT_NORMAL: should be 0, is ".@count($a)."\n";
75 print "\n-- Testing count() on an empty sub-array --\n";
77 print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n";
78 print "COUNT_RECURSIVE: should be 5, is ".count($arr, COUNT_RECURSIVE)."\n";
80 echo "\n-- Testing count() on objects with Countable interface --\n";
86 public function count() {
92 print "COUNT_NORMAL: should be 3, is ".count($obj)."\n";
95 echo "\n-- Testing count() on resource type --\n";
101 var_dump(count($arr_resource));
103 echo "\n-- Testing count() on arrays containing references --\n";
109 for( $i =0; $i < count( $mode_arr ); $i++) {
110 echo "For mode '$mode_arr[$i]' count is => ";
111 var_dump(count($arr, $mode_arr[$i]));
116 var_dump( count() ); // No. of args = 0
117 var_dump( count(array(), COUNT_NORMAL, 100) ); // No. of args > expected
120 var_dump( count("string", ABCD) );
121 var_dump( count(100, "string") );
122 var_dump( count(array(), "") );
131 *** Testing basic functionality of count() function ***
134 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
137 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
147 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
150 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
154 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
161 *** Testing possible variations of count() function on arrays ***
194 -- Testing count() on constants with no second argument --
196 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
199 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
202 -- Testing count() on NULL and Unset variables --
204 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
207 Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
211 -- Testing count() on an empty sub-array --
215 -- Testing count() on objects with Countable interface --
218 -- Testing count() on resource type --
221 -- Testing count() on arrays containing references --
222 For mode '0' count is => int(3)
223 For mode '1' count is => int(9)
224 For mode '0' count is => int(3)
225 For mode '1' count is => int(9)
226 For mode '-1' count is => int(3)
227 For mode '-1.45' count is => int(3)
228 For mode '2' count is => int(3)
229 For mode '1' count is => int(9)
230 For mode '' count is => int(3)
231 For mode '' count is => int(3)
234 Warning: count() expects at least 1 parameter, 0 given in %s on line %d
237 Warning: count() expects at most 2 parameters, 3 given in %s on line %d
242 Warning: count() expects parameter 2 to be int, %s given in %s on line %d
245 Warning: count() expects parameter 2 to be int, %s given in %s on line %d
248 Warning: count() expects parameter 2 to be int, %s given in %s on line %d