Home  >  Article  >  Backend Development  >  PHP Get Web Page File Size Example Code_PHP Tutorial

PHP Get Web Page File Size Example Code_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:41:07962browse

  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.  
  11. fwrite($fp, $out);   
  12. $i=0;   
  13. while($i<2)   
  14. {   
  15.     $i ;   
  16. $con.=fread($fp,500);   
  17. }   
  18. //   
  19. echo $con;   
  20. //定义取出的字节数   
  21. preg_match("/Content-Length:.?(d )/", $con, $matches);   
  22. $size = $matches[1];   
  23. echo $size;   
  24. ?>

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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn