您好,欢迎访问一九零五行业门户网

php 判断远路图片是否有效

php 判断远程图片是否有效
?
$url = http://www.iteye.com/upload/logo/user/275746/46a4c886-427e-3554-b195-083430beb92a.jpg; echo $url
; $arr = get_headers($url,1); echo $arr[content-type]; //image/jpeg
以下是手册上的:
get_headers() 返回一个数组,包含有服务器响应一个 http 请求所发送的标头。如果失败则返回 false 并发出一条 e_warning 级别的错误信息。
如果将可选的 format 参数设为 1,则 get_headers() 会解析相应的信息并设定数组的键名。
上例的输出类似于:array( [0] => http/1.1 200 ok [1] => date: sat, 29 may 2004 12:28:13 gmt [2] => server: apache/1.3.27 (unix) (red-hat/linux) [3] => last-modified: wed, 08 jan 2003 23:11:55 gmt [4] => etag: 3f80f-1b6-3e1cb03b [5] => accept-ranges: bytes [6] => content-length: 438 [7] => connection: close [8] => content-type: text/html)array( [0] => http/1.1 200 ok [date] => sat, 29 may 2004 12:28:14 gmt [server] => apache/1.3.27 (unix) (red-hat/linux) [last-modified] => wed, 08 jan 2003 23:11:55 gmt [etag] => 3f80f-1b6-3e1cb03b [accept-ranges] => bytes [content-length] => 438 [connection] => close [content-type] => text/html)
其它类似信息

推荐信息