php 实现异步发送请求
function fspost($path,$data){ $host = request()->host(); $post = http_build_query($data); $len = strlen($post); $fp = fsockopen( $host , 80, $errno, $errstr, 3); if ($fp) { $header = "POST $path HTTP/1.1\r\n"; $header .= "Host: $host\r\n"; $header .= "Content-type: application/x-www-form-urlencoded\r\n"; $header .= "Connection: Close\r\n"; $header .= "Content-Length: $len\r\n"; $header .= "\r\n"; $header .= $post."\r\n"; fwrite($fp, $header); fclose($fp); } }