2018-04-13 PHP异步处理
2018-04-13 本文已影响15人
小虾米QAQ
public function toRequest($url,$param)
{
$urlInfo = parse_url($url);
$host = $urlInfo['host'];
$path = $urlInfo['path'];
$query = isset($param)? http_build_query($param): '';
$port = 80;
$errno = 0;
$errstr = '';
$timeout = 10;
$fp = fsockopen($host,$port,$errno,$errstr,$timeout);
$out = "POST " . $path . " HTTP/1.1\r\n";
$out .= "host:" . $host . "\r\n";
$out .= "content-length:" . strlen($query). "\r\n";
$out .= "content-type:application/x-www-form-urlencoded\r\n";
$out .= "connection:close\r\n\r\n";
$out .= $query;
ignore_user_abort(true);// 忽略客户端断开
set_time_limit(0);
fputs($fp,$out);
fclose($fp);
}