Kiedy czytałem pytania do Zend Certified PHP Engineer 5.5, zobaczyłem pytanie o anonimową funkcję, ale muszę wyjaśnić, jak to działa.php Anonimowa funkcja
function z($x)
{
return function($y) use ($x)
{
return str_repeat($y , $x);
};
}
$a = z(2);
$b = z(3);
echo $a(3).$b(2);
Wyjście dla tego kodu jest:
33222
Ale w nagłówku funkcji jest tylko $x
parametr skąd $y
tam wartość!