thinkphp 钩子(hook)的冷知识
钩子注册
Hook::add('xxx', 'app\common\behavior\Aaa');
$guahaoStatus = Hook::listen('xxx',$sy_id);
预期的返回数据
array(2) {
[0] => int(-1)
[1] => string(9) "已取消"
}
实际的返回数据
array(1) {
array(2) {
[0] => int(-1)
[1] => string(9) "已取消"
}
}
Hook::listen
返回的数组,会被包裹一层。
解决方式
$guahaoStatus = Hook::listen('xxx',$sy_id,null,true);
本文作者:Fly
本文链接:https://www.xuehuafei.cn/archives/cold-knowledge-of-thinkphp-hooks.html
版权声明:白嫖注明出处