当前位置:Gxlcms > PHP教程 > PHP获取网页文件大小实例代码_PHP教程

PHP获取网页文件大小实例代码_PHP教程

时间:2021-07-01 10:21:17 帮助过:4人阅读

  1. $host="www.ite5e.com";
  2. $fp = fsockopen("$host", 80, $errno, $errstr, 30);
  3. if (!$fp) {
  4. echo "$errstr ($errno)
    ";
  5. } else {
  6. $out = "GET / HTTP/1.1 ";
  7. $out .= "Host: $host ";
  8. $out .= "Connection: Close ";
  9. }
  10. fwrite($fp, $out);
  11. $i=0;
  12. while($i<2)
  13. {
  14. $i ;
  15. $con.=fread($fp,500);
  16. }
  17. //
  18. echo $con;
  19. //定义取出的字节数
  20. preg_match("/Content-Length:.?(d )/", $con, $matches);
  21. $size = $matches[1];
  22. echo $size;
  23. ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486166.htmlTechArticle?php $host="www.ite5e.com"; $fp = fsockopen("$host", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)br /"; } else { $out = "GET / HTTP/1.1"; $out .= "Host: $host"; $ou...

人气教程排行