Press "Enter" to skip to content

深入理解PHP之匿名函数

PHP中, 传递Callback的方式, 一直很丑陋. 在PHP5.3以前, 我们只有俩种选择:

1. 字符串的函数名
2. 使用create_function的返回值

在PHP5.3以后, 我们多了一个选择, 也就是Closure,

$func = function () { ... };
array_walk($arr, $func);

Filed in PHP应用
with 15 Comments