ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
header方法获取当前请求的HTTP请求头信息: ``` Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 Host: www.example.com Connection: Keep-Alive ``` ``` $info = $this->header(); echo $info['accept']; echo $info['accept-encoding']; echo $info['user-agent']; ``` 也可以直接获取某个请求头信息,例如: ``` $agent = $this->header('user-agent'); ``` HTTP请求头信息的名称不区分大小写,并且_会自动转换为-,所以下面的写法都是等效的: ``` $agent = $this->header('user-agent'); $agent = $this->header('User-Agent'); $agent = $this->header('User_Agent'); $agent = $this->header('USER_AGENT'); ```