请求变量
~~~
use think\facade\Request;
Request::param('name');
Request::param();全部请求变量 返回数组
Request::param(['name', 'email']); 多个变量
Request::param('a','1') $a不存在使用默认值1
Request::param('username','','strip_tags'); 参数过滤 去掉html标签 htmlspecialchars转换成实体入库 strtolower小写
Request::header(); 请求头数组,支持单个 cookie
input("name");
Request::session();获取 $_SESSION 变量
Request::cookie();获取 $_COOKIE 变量
Request::server();获取 $_SERVER 变量
Request::env();返回env数组
Request::file();获取 $_FILES 变量
Request::baseUrl(); /index/index
Request::host(true); 域名:www.baidu.com,默认无参数包含端口:80
Request::url(1); 完整域名和地址 http://tp6.api.shanliwawa.top:80/index/index
Request::domain(1) http://tp6.api.shanliwawa.top
Request::time() 请求时间戳
Request::app() 应用名 index
Request::controller() 控制器 Index 参数true小写
Request::action() 操作 index 参数true 小写
Request::method(true); 请求类型获取 GET
isGet isPost isPut isDelete isAjax isMobile isHead 判断是否某种类型
Request::has('id','get'); 检测变量id是否存在
url('index/hello', ['id'=>5,'name'=>'李白'],'do'); http://tp6.api.shanliwawa.top/index/hello/李白.do?id=5
url('index/hello#aa'); 锚点
Cache::set('name', $value, 3600); 1小时后过期
Cache::get('name'); 获取缓存
多缓存类型配置
return [
// 缓存类型为File
'type' => 'redis',
// 全局缓存有效期(0为永久有效),开发下一定要设置-1 否在刷新后 还在
'expire'=> -1,
// 缓存前缀
'prefix'=> 'think',
// 缓存目录
'host' => '127.0.0.1',
];
return [
// 使用复合缓存类型
'type' => 'complex',
// 默认使用的缓存
'default' => [
// 驱动方式
'type' => 'file',
// 缓存保存目录
'path' => '../runtime/default',
],
// 文件缓存
'file' => [
// 驱动方式
'type' => 'file',
// 设置不同的缓存保存目录
'path' => '../runtime/file/',
],
// redis缓存
'redis