Thinkphp5 method of obtaining request headers: 1. Obtain all the information in the request header through the "$info=Request::instance()->header();" method; 2. Use "$accept= Request::instance()->header('accept');" method obtains the information in a request header.
The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.
How to get request headers in thinkphp5?
ThinkPHP5 Obtain HTTP request header information
Use the header method in the Request object to obtain it.
Get all the information in the request header:
$info = Request::instance()->header();
获取某个请求头中的信息: $accept = Request::instance()->header('accept');
The name of the HTTP request header information is not case-sensitive, and _ will be automatically converted to -
Recommended learning: "thinkPHP video tutorial》
The above is the detailed content of How to get request headers in thinkphp5. For more information, please follow other related articles on the PHP Chinese website!