这个函数读取一个url
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
但我想无缓冲地读取它,所以我可以读取无缓冲的 cgi 脚本,例如,在加载时分析它? 我如何在 php 中执行此操作?
最佳答案
您可以使用 fsockopen(),例如此处给出的第一个示例:http://www.php.net/manual/en/function.fsockopen.php
关于php - 读取 url 内容,无缓冲的 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4352947/