count_variation3.phpt 676 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Test count() function : usage variations - Infinitely recursive array
  3. --FILE--
  4. <?php
  5. /*
  6. * Pass count() an infinitely recursive array as $var argument
  7. * This will stop the script before it reaches the end.
  8. */
  9. echo "*** Testing count() : usage variations ***\n";
  10. $array1 = array (1, 2, 'three');
  11. // get an infinitely recursive array
  12. $array1[] = &$array1;
  13. echo "\n-- \$mode not set: --\n";
  14. var_dump(count ($array1));
  15. echo "\n-- \$mode = 1: --\n";
  16. var_dump(count ($array1, 1));
  17. echo "Done";
  18. ?>
  19. --EXPECTF--
  20. *** Testing count() : usage variations ***
  21. -- $mode not set: --
  22. int(4)
  23. -- $mode = 1: --
  24. Warning: count(): Recursion detected in %s on line %d
  25. int(4)
  26. Done