#49717 [Com]: Unable to recurse within an anonymous function
| From: | oliver dot saunders at gmail dot com | Date: | Tue, 29 Sep 2009 22:08:11 +0000 |
| Subject: | #49717 [Com]: Unable to recurse within an anonymous function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143065@lists.php.net to get a copy of this message | ||
ID: 49717
Comment by: oliver dot saunders at gmail dot com
Reported By: oliver dot saunders at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Mac OS X
PHP Version: 5.3.0
New Comment:
You can workaround like this:
$c = function($self, $n) {
if ($n > 0) {
echo $n . PHP_EOL;
$self($self, $n - 1); } };
$c($c, 4);
...but that's not really the point.
Previous Comments:
------------------------------------------------------------------------
[2009-09-29 22:06:26] oliver dot saunders at gmail dot com
Description:
------------
Unable to recurse within an anonymous function.
Reproduce code:
---------------
$c = function($n) use($c) {
if ($n > 0) {
echo $n . PHP_EOL;
$c($n - 1); } };
$c(4);
Expected result:
----------------
4
3
2
1
Actual result:
--------------
4
Fatal error: Function name must be a string in Command line code on
line
4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49717&edit=1