4种PHP回调函数风格
2024-08-24 12:39:27
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'));
最新文章
- SharePoint如何将使列表不被爬网爬到。
- java后台对前端输入的特殊字符进行转义
- JAVA_OPTS
- rh6安装oracle11g+ASM
- ubuntu12.04 登录黑屏
- Java-Web监听器
- 一个坑:java.sql.ResultSet.getInt==》the column value; if the value is SQL NULL, the value returned is 0
- 安装github for windows问题解决
- T-SQL性能调整——信息收集
- NOI 2005维护数列
- Json对象遍历
- 大数据mapreduce二分法ip定位之Python实现
- Node+Express+MongoDB + Socket.io搭建实时聊天应用实战教程(三)--前后端环境配置
- java主线程等待所有子线程执行完毕在执行(常见面试题)
- PCL常见错误集锦
- Logger.getLogger()和LogFactory.getLog()的区别
- 安装nginx和nginx-gridfs和mongodb
- [总结帖] 后端MVC V.S. 前端MVVM
- AC日记——双栈排序 洛谷 P1155
- salt-minion和salt-master之间如何重新认证
热门文章
- vagrant特性——基于docker开发环境(docker和vagrant的结合)-2-命令
- 常用lua代码块
- OpenCV——图像金字塔和图片尺寸缩放
- java.lang.NoClassDefFoundError: org.androidpn.client.PersistentConnectionListener
- 第16章 STM32中断应用概览
- Loopback接口用途---用作管理地址。
- EXCEL2007出错了无法使用文档中的ActiveX 控件
- kettle学习笔记(三)——kettle资源库、运行方式与日志
- PySide图形界面开发(一)
- Metasploit简单应用