<?php
$file = file_get_contents($url);
echo strlen($file);
?>
<?php
$header_array = get_headers($url
$size = $header_array[
echo $size;
?>
PS:
需要打開allow_url_fopen!
如未打開會顯示
Warning: get_headers() [function
<?php
function get_file_size($url) {
$url = parse_url($url);
if (empty($url[
return false;
}
$url[
$url[
$fp = fsockopen($url[
if($fp) {
fputs($fp
fputs($fp
while (!feof($fp)) {
$str = fgets($fp);
if (trim($str) ==
break;
}elseif(preg_match(
return trim($arr[
}
}
fclose ( $fp);
return false;
}else {
return false;
}
}
?>
From:http://tw.wingwit.com/Article/program/PHP/201311/21084.html