在php中从标题响应回显项目
我想单独回显此标题响应中的项目在php中从标题响应回显项目,php,header,Php,Header,我想单独回显此标题响应中的项目 $headers = get_headers('https://businesspeopleclub.com/demo-files/Sample-Zip-file.zip', TRUE); 这是数组中的响应 Array ( [0] => HTTP/1.1 200 OK [Date] => Tue, 26 May 2020 02:23:04 GMT [Server] => Apache [Last-Modifie
$headers = get_headers('https://businesspeopleclub.com/demo-files/Sample-Zip-file.zip', TRUE);
这是数组中的响应
Array
(
[0] => HTTP/1.1 200 OK
[Date] => Tue, 26 May 2020 02:23:04 GMT
[Server] => Apache
[Last-Modified] => Sun, 27 Jan 2019 21:02:55 GMT
[Accept-Ranges] => bytes
[Content-Length] => 8851
[Vary] => Accept-Encoding,User-Agent
[Connection] => close
[Content-Type] => application/zip
)
示例-我想回显文件大小,但它不显示
$filesize = $headers['content-length'];
echo$filesize;
你必须注意书信箱
$headers['Content-Length']; !== $headers['content-length']; //true
'Content-Length' !== 'content-length'; //true
要运行的代码是:
$filesize = $headers['Content-Length'];
echo$filesize;
php中关联数组中的键区分大小写,请尝试
$headers['Content-Length']
Hi-catcon!你是对的。它区分大小写。非常感谢。嗨,塔吉尼。它区分大小写。非常感谢。