In php, we can create functions with recursion as follows.
function quack($quack = 1)
{
if ($quacks >= 1) {
echo "Quack";
$quack--;
quack($quacks);
}
}
Or, in case of avoiding problem with "renames" function.
function quack($quack = 1)
{
$func = __FUNCTION__;
if ($quacks >= 1) {
echo "Quack";
$quack--;
$func($quacks);
}
}
But what about anonymous functions?
Example:
$quack = function ($quacks)
{
if ($quacks >= 1) {
echo "Quack";
$quacks--;
// como chamo $quack aqui?
}
}
How could I make the anonymous function $quack
into a recursive function?