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
";
        $header .= "Host: $host
";
        $header .= "Content-type: application/x-www-form-urlencoded
";
        $header .= "Connection: Close
";
        $header .= "Content-Length: $len
";
        $header .= "
";
        $header .= $post."
";

        fwrite($fp, $header);

        fclose($fp);
    }
}
原文地址:https://www.cnblogs.com/lixihuan/p/15314694.html