Read url content, unbuffered php
This function reads an 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;
}
but I want to read it unbuffered, so I can read an unbuffered cgi-script, e.g., to analyze it while it is loading? How 开发者_运维技巧do I do this in php?
You could use fsockopen(), such as in the first example given here: http://www.php.net/manual/en/function.fsockopen.php
精彩评论