array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.apache-request-headers.php', 1 => 'apache_request_headers', ), 'up' => array ( 0 => 'ref.apache.php', 1 => 'Apache 函数', ), 'prev' => array ( 0 => 'function.apache-note.php', 1 => 'apache_note', ), 'next' => array ( 0 => 'function.apache-response-headers.php', 1 => 'apache_response_headers', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/apache/functions/apache-request-headers.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
apache_request_headers — 获取全部 HTTP 请求头信息
此函数没有参数。
包含当前请求所有头信息的数组,失败返回
false
。
版本 | 说明 |
---|---|
7.3.0 | 此函数可用于 FPM SAPI 模式。 |
示例 #1 apache_request_headers() 示例
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
?>
以上示例的输出类似于:
Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 Host: www.example.com Connection: Keep-Alive