The answer I'd previously accepted didn't work. It still waited for responses. This does work though, taken from How do I make an asynchronous GET request in PHP?
function post_without_wait($url, $params)
{
foreach ($params as $key => &$val) {
if (is_array($val)) $val = implode(',', $val);
$post_params[] = $key.'='.urlencode($val);
}
$post_string = implode('&', $post_params);
$parts=parse_url($url);
$fp = fsockopen($parts['host'],
isset($parts['port'])?$parts['port']:80,
$errno, $errstr, 30);
$out = "POST ".$parts['path']." HTTP/1.1
";
$out.= "Host: ".$parts['host']."
";
$out.= "Content-Type: application/x-www-form-urlencoded
";
$out.= "Content-Length: ".strlen($post_string)."
";
$out.= "Connection: Close
";
if (isset($post_string)) $out.= $post_string;
fwrite($fp, $out);
fclose($fp);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…