Home > Backend Development > PHP Tutorial > PHP asynchronous request file implements multi-threaded code

PHP asynchronous request file implements multi-threaded code

WBOY
Release: 2016-07-25 08:54:46
Original
1038 people have browsed it
  1. $content='';

  2. $fp = fsockopen("bbs.it-home.org", 80, $errno, $errstr, 30);
  3. if (!$fp) {
  4. echo "$errstr ($errno)
    n";
  5. } else {
  6. $out = "POST /test.php?id=5".$content." HTTP/1.1rn";
  7. $out .= "Host:www.php100.comrn";
  8. $out .= "Content-Length: ". strlen($content) ."rn";
  9. $out .= "Connection: Closernrn";
  10. $out .= $content;
  11. $out .= "rnrn";
  12. fwrite($fp, $out);

  13. /*//忽略执行结果

  14. while (!feof($fp)) {
  15. echo fgets($fp, strlen($content));
  16. } */
  17. echo 'zhinxging';
  18. fclose($fp);
  19. }

复制代码


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template