header();" method; 2. Use "$accept=Request::instance()- >header('accept');" method obtains the information in a request header."/> header();" method; 2. Use "$accept=Request::instance()- >header('accept');" method obtains the information in a request header.">

Home >PHP Framework >ThinkPHP >How to get request headers in thinkphp5

How to get request headers in thinkphp5

藏色散人
藏色散人Original
2022-12-05 10:48:372424browse

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.

How to get request headers in thinkphp5

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn