You cannot polyfill http_get_last_response_headers because the $http_response_header has to be in scope for it to be read. As soon as you put it in a function, it's out of scope.http_get_last_response_headers
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
http_get_last_response_headers
Референца за `function.http-get-last-response-headers.php` со подобрена типографија и навигација.
http_get_last_response_headers
Класата Dom\DtdNamedNodeMap
http_get_last_response_headers — Преземи ги последните HTTP заглавија на одговорот
= NULL
Враќа array кои ги содржат последните HTTP
заглавија на одговорот примени преку
функција. Кога се користи. Ако нема, " null " се враќа наместо тоа.
Параметри
Оваа функција нема параметри.
Вратени вредности
Враќа индексиран array of HTTP заглавија кои беа примени додека се користеше
функција. Кога се користи. Ако нема, " null " се враќа наместо тоа.
Примери
Пример #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"
}
Види Исто така
- http_clear_last_response_headers() - Преземање на последните HTTP одговори за заглавјата
Белешки од корисници 2 забелешки
For PHP versions < 8.4, you can write a polyfill to be prepared for the future:
if ( ! function_exists("http_get_last_response_headers") ) {
function http_get_last_response_headers() {
if ( ! isset($http_response_header) ) {
return null;
}
return $http_response_header;
}
}