New from the PHP 10.0 blog today is this look at trying to set up recursive closures in the upcoming PHP 5.3 release (it includes closures, but it doesn't look like this is possible). Instead, Stas suggests the Y combinator method as an alternative.
One of the ways to do it is to use Y combinator function, which allows, by application of dark magic and friendly spirits from other dimensions, to convert non-recursive code to recursive code. [...] Doing Y-combinator in PHP was attempted before (and here), but now I think it works better. It could be even nicer if PHP syntax allowed chaining function invocations - ($foo($bar))($baz) - but for now it doesn't.
His (less than ideal) first method throws in some variable variables and a separate factoral function and his second passes in a factoral value of itself to call itself the correct number of times.