您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP支持回调的函数有哪些?

2026/6/13 9:57:03发布14次查看
php支持回调的函数有:1、匿名函数,代码为【$server->on 'request'】;2、类静态方法,代码为【static function test $req】;3、函数,代码为【my_onrequest $req】。
php支持回调的函数有:
1、匿名函数
$server->on('request', function ($req, $resp) use ($a, $b, $c) { echo "hello world";});
可使用use向匿名函数传递参数
2、类静态方法
class a{ static function test($req, $resp) { echo "hello world"; }}$server->on('request', 'a::test');$server->on('request', array('a', 'test'));
3、函数
function my_onrequest($req, $resp){ echo "hello world";}$server->on('request', 'my_onrequest');
4、对象方法
class a{ function test($req, $resp) { echo "hello world"; }}$object = new a();$server->on('request', array($object, 'test'));
相关学习推荐:php编程从入门到精通
以上就是php支持回调的函数有哪些?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product