使用php识别文件头

Rah*_*l R 0 php

我想找到托管在外部服务器上的文件类型.我尝试了get_headers()函数,但它返回了一个头数组,我只需要内容类型.数组根据文件的顺序不同,因此无法使用数组元素的位置.请给我一个解决方案.

Seb*_*olm 6

如果将format参数设置为1,则它将创建标题的关联数组:

$headers = get_headers($url, 1);
$content_type = $headers['Content-Type'];
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅文档get_headers.