$value) { if (is_array($value)) { $date[$key] = serialize($value); } else { $date[$key] = $value; } } } if ($method == "GET") { $query = $date ? http_build_query($date) : ''; $path .= "?" . $query; } else { $query = json_encode($date); } //http消息头 $out = $method . " " . $path . " HTTP/1.1\r\n"; $out .= "HOST: " . $host . "\r\n"; if ($method == "POST") { $out .= "Content-Length:" . strlen($query) . "\r\n"; } $out .= "Accept: application/json, text/plain, */*\r\n"; $out .= "Access-Control-Allow-Credentials: true\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Connection: Close\r\n\r\n"; if ($method == "POST") { $out .= $query; } fputs($fp, $out); usleep(20000); //忽略执行结果 /*while (!feof($fp)) { echo fgets($fp, 128); }*/ fclose($fp); return true; } /* $p = array( 'test'=>1222, 'test1'=>2222, ); var_dump(request_asynchronous('/test.php', 'GET', $p, 'https://png.cm')); */