<?php
$test = NULL;
$test = function ($a) use (&$test) {
    echo $a;
    $a --;

    if ($a > 0) {
        return $test($a);
    }
};

$test(10);

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