大网数据广告活动
PHP 语言与运行手册

http_get_last_response_headers · Retrieve last HTTP response headers

· 52CE 我爱测

http_get_last_response_headers — Retrieve last HTTP response headers

http_get_last_response_headers

(PHP 8 >= 8.4.0)

http_get_last_response_headers — Retrieve last HTTP response headers

说明

function http_get_last_response_headers(): ?array

Returns an array containing the last HTTP response headers received via the HTTP wrapper. If there are none, null is returned instead.

参数

此函数没有参数。

返回值

Returns an indexed array of HTTP headers which were received while using the HTTP wrapper. If there are none, null is returned instead.

示例

示例 #1 http_get_last_response_headers() example

Description.

<?php
file_get_contents("http://example.com");
var_dump(http_get_last_response_headers());
?>

以上示例的输出类似于:

array(14) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(20) "Accept-Ranges: bytes"
  [2]=>
  string(11) "Age: 326940"
  [3]=>
  string(29) "Cache-Control: max-age=604800"
  [4]=>
  string(38) "Content-Type: text/html; charset=UTF-8"
  [5]=>
  string(35) "Date: Mon, 11 Nov 2024 13:34:09 GMT"
  [6]=>
  string(23) "Etag: "3147526947+gzip""
  [7]=>
  string(38) "Expires: Mon, 18 Nov 2024 13:34:09 GMT"
  [8]=>
  string(44) "Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT"
  [9]=>
  string(24) "Server: ECAcc (nyd/D16C)"
  [10]=>
  string(21) "Vary: Accept-Encoding"
  [11]=>
  string(12) "X-Cache: HIT"
  [12]=>
  string(20) "Content-Length: 1256"
  [13]=>
  string(17) "Connection: close"
}

参见

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。