Annotation of embedaddon/php/ext/standard/tests/array/count_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test count() function : usage variations - Infinitely recursive array
3: --FILE--
4: <?php
5: /* Prototype : int count(mixed $var [, int $mode])
6: * Description: Count the number of elements in a variable (usually an array)
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Pass count() an infinitely recursive array as $var argument
12: * This will stop the script before it reaches the end.
13: */
14:
15: echo "*** Testing count() : usage variations ***\n";
16:
17: $array1 = array (1, 2, 'three');
18: // get an infinitely recursive array
19: $array1[] = &$array1;
20:
21: echo "\n-- \$mode not set: --\n";
22: var_dump(count ($array1));
23:
24: echo "\n-- \$mode = 1: --\n";
25: var_dump(count ($array1, 1));
26:
27: echo "Done";
28: ?>
29: --EXPECTF--
30: *** Testing count() : usage variations ***
31:
32: -- $mode not set: --
33: int(4)
34:
35: -- $mode = 1: --
36:
37: Warning: count(): recursion detected in %s on line %d
38: int(12)
39: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>