它不存在,但您可以使用以下
$file = "file.html";
var_dump(fileHeaders($file));
输出
array
0 => string 'HTTP/1.1 200 OK' (length=15)
1 => string 'Date: Thu, 28 Jun 2012 22:11:14 GMT' (length=35)
2 => string 'Pragma: no-cache' (length=16)
3 => string 'Cache-Control: must-revalidate, no-store' (length=40)
4 => string 'Expires: Thu, 01 Jan 1970 00:00:00 GMT' (length=38)
5 => string 'Content-Length: 1234' (length=20)
6 => string 'Connection: close' (length=17)
7 => string 'Content-Type: text/html' (length=23)
8 => string '' (length=0)
使用的功能
function fileHeaders($file) {
$content = file_get_contents($file, null, null, 0, 1000);
$content = trim($content);
if (stripos($content, "HTTP") === 0) {
return array_map("trim", explode("\n", strtok($content, "<")));
}
return false;
}