ThinkPHPthinkphp5.0 | 请求类型请求伪装header头信息伪静态判断请求类型 // 是否为 GET 请求 if (Request::instance()->isGet()) echo "当前为 GET 请求"; // 是否为 POST 请求 if (Request::instance()->isPost()) echo "当前为 POST 请求"; // 是否为 PUT 请求 if (Request::instance(作者王明昌发布时间2019-02-11复制判断请求类型 // 是否为 GET 请求 if (Request::instance()->isGet()) echo "当前为 GET 请求"; // 是否为 POST 请求 if (Request::instance()->isPost()) echo "当前为 POST 请求"; // 是否为 PUT 请求 if (Request::instance()->isPut()) echo "当前为 PUT 请求"; // 是否为 DELETE 请求 if (Request::instance()->isDelete()) echo "当前为 DELETE 请求"; // 是否为 Ajax 请求 if (Request::instance()->isAjax()) echo "当前为 Ajax 请求"; // 是否为 Pjax 请求 if (Request::instance()->isPjax()) echo "当前为 Pjax 请求"; // 是否为手机访问 if (Request::instance()->isMobile()) echo "当前为手机访问"; // 是否为 HEAD 请求 if (Request::instance()->isHead()) echo "当前为 HEAD 请求"; // 是否为 Patch 请求 if (Request::instance()->isPatch()) echo "当前为 PATCH 请求"; // 是否为 OPTIONS 请求 if (Request::instance()->isOptions()) echo "当前为 OPTIONS 请求"; // 是否为 cli if (Request::instance()->isCli()) echo "当前为 cli"; // 是否为 cgi if (Request::instance()->isCgi()) echo "当前为 cgi"; if (request()->isGet()) echo "当前为 GET 请求"; 请求伪装 / 表单请求类型伪装变量 'var_method' => '_m', ajax/pjax伪装 对请求进行AJAX请求伪装,如下: http://localhost/index?_ajax=1 或者PJAX请求伪装 http://localhost/index?_pjax=1 如果你需要改变伪装请求的变量名,可以修改应用配置文件: // 表单ajax伪装变量 'var_ajax' => '_a', // 表单pjax伪装变量 'var_pjax' => '_p', header头信息 $info = Request::instance()->header(); echo $info['accept']; echo $info['accept-encoding']; echo $info['user-agent']; $agent = Request::instance()->header('user-agent'); $agent = Request::instance()->header('user-agent'); $agent = Request::instance()->header('User-Agent'); $agent = Request::instance()->header('USER_AGENT'); 伪静态 'url_html_suffix' => 'shtml' 控制器的操作方法中获取当前访问的伪静态后缀,例如: $ext = Request::instance()->ext() // 多个伪静态后缀设置 用|分割 'url_html_suffix' => 'html|shtml|xml' // 关闭伪静态后缀访问 'url_html_suffix' => false,
2018-02-27tp5controller与model使用数据库控制器里使用数据库 use think\Db; $info = Db::table('fly_user')->select();//用些前缀,全部查询 $info = Db::table('fly_u
2018-04-30TP5错误 | A non well formed numeric value encountered数据表字段是create_time timestamp 默认:CURRENT_TIMESTAMP 使用时间会出现以下错误: A non well formed numeric value encoun
2018-02-02tp3.2-if三层嵌套问题if标签 value1 value2 value3 if标签不支持三层嵌套,所以第三层不要用if标签,用eq标签;就能解决三层嵌套。 相等不相等 还有更多比较标签可以使用 http://documen
2018-07-04转载 | ThinkPHP5+Layui实现图片上传加预览 图片 上传图片 layui.use('upload',function(){ var upload = layui.upload, jq = layui.jquery; upload.render