标签:usleep code append get export open txt connect write
两个文件:(1)brief.php主程序文件(2)doRequest.php需要异步处理的程序
brief.php:
$url = ‘localhost:8867‘; echo 123; // 先输出,中间部分为异步处理程序 $fp = fsockopen($url,-1, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /doRequest.php HTTP/1.1\r\n"; $out .= "Host: ".$url."\r\n"; $out .= "Connection: Close\r\n\r\n"; //stream_set_blocking($fp,true); //stream_set_timeout($fp,1); fwrite($fp, $out); usleep(1000); fclose($fp); } echo 4567;
doRequest.php:
echo 123; $param = [‘$_GET‘, ‘$_POST‘]; sleep(2); file_put_contents(‘./dorequest.txt‘, var_export($param, true), FILE_APPEND);
标签:usleep code append get export open txt connect write
原文地址:https://www.cnblogs.com/bneglect/p/11937365.html