title | date | tags |
---|---|---|
[转] 4种PHP回调函数 |
2018-01-03 21:47:33 -0800 |
php |
以Swoole服务事件回调为例
$server->on('Request', function ($req, $resp) {
echo "hello world";
});
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'));