• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP help: fopen() and stream_set_timeout() how do they work together?

timelapse

Senior member
Hello. I am trying to learn how fopen and stream_set_timeout work together. I wrote this little script, to try and force a timeout in fopen (to see if it works) by setting the timeout seconds to zero (with the line stream_set_timeout($fp,0); ) can somebody tell me if what I am doing is correct and/or what might be the problem in my code and/or how can I force the thing to timeout so that I can test this script. Thanks in advance.


$whole = "";
$fp = fopen($url, "r");

stream_set_blocking($fp, FALSE );
stream_set_timeout($fp,0);
$info = stream_get_meta_data($fp);

while(!feof($fp) && !$info['timed_out']){
$content = fgets($fp,1400);
$whole .= $content;
$info = stream_get_meta_data($fp);
}

if($info['timed_out']){
echo "time out!";
}

fclose($fp);
 
Back
Top