🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
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标签 htmlspecialchar s转换成实体入库 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.t op/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', \- 127 -\]; return \[ // 使用复合缓存类型 'type' \=> 'complex', // 默认使用的缓存 'default' \=> \[ // 驱动方式 'type' \=> 'file', // 缓存保存目录 'path' \=> '../runtime/default', \], // 文件缓存 'file' \=> \[ // 驱动方式 'type' \=> 'file', // 设置不同的缓存保存目录 'path' \=> '../runtime/file/', \], // redis缓存 'redis' \=> \[ // 驱动方式 'type' \=> 'redis', // 服务器地址 'host' \=> '127.0.0.1', \], \]; use think\\facade\\Cache; Cache::store('file')\->set('name','123',0); $v \= Cache::store('redis')\->get('name'); Cache::store('default')\->get('name');文件缓存 Cache::delete('name'); Cache::clear(); Cache::set('name', \[1,2,3\]); Cache::push('name', 4); Cache::remember('start\_time', time()); 不存在则创建 Cache::inc('name',1); 自增1 Cache::dec('name',1); 自减1 $redis \= Cache::handler(); redis对象 配置redis session return \[ 'type' \=> 'redis', 'prefix' \=> 'think', 'auto\_start' \=> true, // redis主机 'host' \=> '127.0.0.1', // redis端口 'port' \=> 6379, // 密码 'password' \=> '', \] \- 128 -session('name', \['thinkphp'\]); 设置支持字符串 数组 session('name');获取 session('name', null);删除 session(null);清空 cookie('name', 'value', 3600); 设置不支持数组,序列化后存储 cookie('name'); cookie('name', null); cookie('think\_lang','en-us');//设置语言类型 lang('add user error');//翻译 config('cache.type') 读取配置