PHP手册说明
$this在PHP 5.4.0之前无法使用匿名函数
在匿名功能页面上.但我发现我可以通过赋值$this给变量并将变量传递给use函数定义中的语句来使其工作.
$CI = $this;
$callback = function () use ($CI) {
$CI->public_method();
};
Run Code Online (Sandbox Code Playgroud)
这是一个好习惯吗?
有没有更好的方法来$this使用PHP 5.3 访问匿名函数?