Can you make a PHP function recursive without repeating it's name?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-04-27T05:33:14Z Indexed on 2010/04/27 5:53 UTC
Read the original article Hit count: 254

Filed under:
|

It's always bugged me a recursive function needs to name itself, when a instantiated class can use $this and a static method can use self etc.

Is there a similar way to do this in a recursive function without naming it again (just to cut down on maintenance)?

Obviously I could use call_user_func or the __FUNCTION__ constant but I would prefer something less ugly.

Update

Thanks for your answers. I might stick to including the function name for simple functions, and make take the other approaches for anything more complicated.

© Stack Overflow or respective owner

Related posts about php

Related posts about recursion