支持回调处理 php函数,PHP支持回调的函数有哪些
PHP支持回調的函數有哪些
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支持回調的函數有哪些?的教程已介紹完畢,更多請關注跳墻網其他文章教程!
PHP支持回調的函數有哪些相關教程
總結
以上是生活随笔為你收集整理的支持回调处理 php函数,PHP支持回调的函数有哪些的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php pg connect,pg_co
- 下一篇: nginx重新加载php,如何使用ngi