Doc #63406 [Com]: Count *does* detect infinite recursion
| From: | mail+php at requinix dot net | Date: | Sat, 03 Nov 2012 01:07:18 +0000 |
| Subject: | Doc #63406 [Com]: Count *does* detect infinite recursion | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9048@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63406&edit=1
ID: 63406
Comment by: mail+php at requinix dot net
Reported by: n at p12a dot org dot uk
Summary: Count *does* detect infinite recursion
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: master-Git-2012-10-31 (Git)
Block user comment: N
Private report: N
New Comment:
...and the number may be wildly inaccurate. Sounds like a bug: counts first and
stops recursion second?
$a = array(1, 2, 3);
$a[] =& $a;
$a[] =& $a;
$a[] =& $a;
echo count($a, COUNT_RECURSIVE); // 78
Did you know you can easily submit changes to the online documentation? Look for
the [edit] in the top-right corner of manual pages.
I've submitted some changes for you:
"count: detects recursion (bug #63406)"
http://edit.php.net/?patchID=761&project=PHP
Previous Comments:
------------------------------------------------------------------------
[2012-10-31 19:37:23] n at p12a dot org dot uk
Description:
------------
---
From manual page: http://www.php.net/function.count#refsect1-function.count-
parameters
---
The manual says "count() does not detect infinite recursion". But count() does.
Test script:
---------------
$a = array();
$a[] = &$a;
echo count($a, 1), "\n"
Expected result:
----------------
Most probably an out-of-memory error, which is what I get when infinitely
recursing in a user-defined function.
Actual result:
--------------
PHP Warning: count(): recursion detected in Command line code on line 1
3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63406&edit=1