Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中从标题响应回显项目_Php_Header - Fatal编程技术网

在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!你是对的。它区分大小写。非常感谢。嗨,塔吉尼。它区分大小写。非常感谢。