在PHP中,使用fsockopen是否可以保存等待服务器响应?
为了发送HTTP请求,可以使用fsockopen、file\u get\u contents或curl。在PHP中,使用fsockopen是否可以保存等待服务器响应?,php,file-get-contents,fsockopen,Php,File Get Contents,Fsockopen,为了发送HTTP请求,可以使用fsockopen、file\u get\u contents或curl。 如果我对服务器的响应不感兴趣,并且希望触发并忘记一个查询,那么使用fsockopen是否可以节省等待服务器响应的时间 我想比较一下: $fp = fsockopen("example.com", 80, $errno, $errstr, 30); $req = "GET /hello?foo=bar HTTP/1.1\r\n"; $req .= &q
如果我对服务器的响应不感兴趣,并且希望触发并忘记一个查询,那么使用fsockopen是否可以节省等待服务器响应的时间 我想比较一下:
$fp = fsockopen("example.com", 80, $errno, $errstr, 30);
$req = "GET /hello?foo=bar HTTP/1.1\r\n";
$req .= "Host: example.com\r\n";
$req .= "Connection: Close\r\n\r\n";
fwrite($fp, $req);
fclose($fp);
为此:
file_get_contents("http://example.com:80/hello?foo=bar");