//方法
function get_img_size($uri)
{
ob_start();
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1); //nobody是关键
$okay = curl_exec($ch);
curl_close($ch);
$head = ob_get_contents();
ob_end_clean();
$regex = '/Content-Length:\s+(\d+)/';
preg_match($regex, $head, $matches);
return $matches[1];
}
//调用
get_img_size("http://xxxxx.xxxx.com/xxx.png");
//输出一个整数