Slim 3 文档(二)-升级指南

版本要求 Slim 3要求PHP 5.5+ 新的路由函数使用说明 $app->get('/', function (Request $req, Response $res, $args = []) { return $res->withStatus(400)->write('Bad Request'); }); 获取GET,POST变量 //args 获取的是路由参数 $app->get('/', function (Request $req, Response $res, $args = []) { $myvar1 = $req->getParam('myvar');

Slim 3 文档(一)-安装

简介 Slim 是一个PHP 的微框架,可以用它快速开发Web应用和API。Slim官网 安装 系统要求 Web 服务器(Nginx|Apache等)支持路由重写 P

PHP函数preg_replace_callback使用

preg_replace_callback — 执行一个正则表达式搜索并且使用一个回调进行替换 示例: <?php preg_replace_callback('/([a-z]{3,})/', function ($match) { echo "<pre>"; var_dump($match); echo "</pre>"; }, '344aaaaa88rrr00aaa'); 结果: array(2) { [0]=> string(5) "aaaaa" [1]=> string(5) "aaaaa" } array(2) { [0]=> string(3) "rrr" [1]=> string(3) "rrr" } array(2) { [0]=> string(3) "aaa" [1]=> string(3) "aaa" }

PHP匿名函数使用理解

匿名函数PHP官网是这么定义的: 匿名函数(Anonymous functions),也叫闭包函数(closures),允许 临时创建一个没有指定

PHP定义对象的字符串值(__tostring)

类: class ToString { } 直接输出类: $tostring = new ToString; echo $tostring; 结果: Catchable fatal error: Object of class ToString could not be converted to string in 使用 __tostring方法后的类: class ToString { public function __tostring() { return 'this class is tostring test'; } } 结果