1--TEST--
2Test 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
15echo "*** Testing count() : usage variations ***\n";
16
17$array1 = array (1, 2, 'three');
18// get an infinitely recursive array
19$array1[] = &$array1;
20
21echo "\n-- \$mode not set: --\n";
22var_dump(count ($array1));
23
24echo "\n-- \$mode = 1: --\n";
25var_dump(count ($array1, 1));
26
27echo "Done";
28?>
29--EXPECTF--
30*** Testing count() : usage variations ***
31
32-- $mode not set: --
33int(4)
34
35-- $mode = 1: --
36
37Warning: count(): recursion detected in %s on line %d
38int(12)
39Done
40