Baidu comes out, it feels good to use fsockopen to achieve asynchronism, it is not actually used in the generation environment, I do not know if there is a pit?
are there any other good solutions?
<?php
$url = "http://www.example.com/doRequest.php";
$param = array(
"name"=>"fdipzone",
"gender"=>"male",
"age"=>30
);
doRequest($url, $param);
function doRequest($url, $param=array()){
$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;
fputs($fp, $out);
fclose($fp);
}
?>