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

Reply via email to