美文网首页我爱编程
2018-04-13 PHP异步处理

2018-04-13 PHP异步处理

作者: 小虾米QAQ | 来源:发表于2018-04-13 18:56 被阅读15次

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);

}

相关文章

网友评论

    本文标题:2018-04-13 PHP异步处理

    本文链接:https://www.haomeiwen.com/subject/qodhkftx.html