PHP支持回调的函数有:一、匿名函数,代码为【$server->on 'Request'】;二、类动态办法,代码为【static function test $req】;三、函数,代码为【my_onRequest $req】。
PHP支持回调的函数有:
一、匿名函数
$server->on('Request', function ($req, $resp) use ($a, $b, $c) { echo "hello world"; });
可以使用use向匿名函数通报参数
二、类动态办法
class A { static function test($req, $resp) { echo "hello world"; } } $server->on('Request', 'A::Test'); $server->on('Request', array('A', 'Test'));
三、函数
function my_onRequest($req, $resp) { echo "hello world"; } $server->on('Request', 'my_onRequest');
四、工具办法
class A { function test($req, $resp) { echo "hello world"; } } $object = new A(); $server->on('Request', array($object, 'test'));
相干学习保举:PHP编程从入门到通晓
以上就是PHP支持回调的函数有哪些?的具体内容,更多请存眷资源魔其它相干文章!
标签: php php教程 回调函数 php故障解决 php使用问题
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!