dominikbulaj
5/30/2016 - 2:20 PM

From http://stackoverflow.com/questions/2480179/anonymous-recursive-php-functions

$factorial = function( $n ) use ( &$factorial ) {
    if( $n == 1 ) return 1;
    return $factorial( $n - 1 ) * $n;
};
print $factorial( 5 );