PHP 获取网页文件大小实例代码
程序员文章站
2022-05-29 16:27:18
...
- $host="www.ite5e.com";
- $fp = fsockopen("$host", 80, $errno, $errstr, 30);
- if (!$fp) {
- echo "$errstr ($errno)
"; - } else {
- $out = "GET / HTTP/1.1 ";
- $out .= "Host: $host ";
- $out .= "Connection: Close ";
- }
- fwrite($fp, $out);
- $i=0;
- while($i
- {
- $i ;
- $con.=fread($fp,500);
- }
- //
- echo $con;
- //定义取出的字节数
- preg_match("/Content-Length:.?(d )/", $con, $matches);
- $size = $matches[1];
- echo $size;
- ?>