PHP 获取网页文件大小实例代码_PHP教程
程序员文章站
2023-12-29 19:11:40
...
- $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;
- ?>