4种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'));

最新文章

  1. SharePoint如何将使列表不被爬网爬到。
  2. java后台对前端输入的特殊字符进行转义
  3. JAVA_OPTS
  4. rh6安装oracle11g+ASM
  5. ubuntu12.04 登录黑屏
  6. Java-Web监听器
  7. 一个坑:java.sql.ResultSet.getInt==》the column value; if the value is SQL NULL, the value returned is 0
  8. 安装github for windows问题解决
  9. T-SQL性能调整——信息收集
  10. NOI 2005维护数列
  11. Json对象遍历
  12. 大数据mapreduce二分法ip定位之Python实现
  13. Node+Express+MongoDB + Socket.io搭建实时聊天应用实战教程(三)--前后端环境配置
  14. java主线程等待所有子线程执行完毕在执行(常见面试题)
  15. PCL常见错误集锦
  16. Logger.getLogger()和LogFactory.getLog()的区别
  17. 安装nginx和nginx-gridfs和mongodb
  18. [总结帖] 后端MVC V.S. 前端MVVM
  19. AC日记——双栈排序 洛谷 P1155
  20. salt-minion和salt-master之间如何重新认证

热门文章

  1. vagrant特性——基于docker开发环境(docker和vagrant的结合)-2-命令
  2. 常用lua代码块
  3. OpenCV——图像金字塔和图片尺寸缩放
  4. java.lang.NoClassDefFoundError: org.androidpn.client.PersistentConnectionListener
  5. 第16章 STM32中断应用概览
  6. Loopback接口用途---用作管理地址。
  7. EXCEL2007出错了无法使用文档中的ActiveX 控件
  8. kettle学习笔记(三)——kettle资源库、运行方式与日志
  9. PySide图形界面开发(一)
  10. Metasploit简单应用