请求类型
有时需要判断 Request 的请求类型,比如 GET、POST 等等;
可以使用 method()方法来判断当前的请求类型,还有很多专用的请求判断
是否为 GET 请求
if (Request::instance()->isGet()) echo "当前为 GET 请求";
是否为 POST 请求
if (Request::instance()->isPost()) echo "当前为 POST 请求";
是否为 Ajax 请求
if (Request::instance()->isAjax()) echo "当前为 Ajax 请求";
其他请求方法类似
使用普通表单提交,通过 method()方法获取类型
return Request::method();
使用 header()方法可以输出 HTTP 头信息,返回是数组类型,也可单信息获取;
dump(Request::header());
dump(Request::header('host'));
0条评论