note 14087 added to function.fgets.php
| From: | verdy_p at wanadoo dot fr | Date: | Mon, 16 Jul 2001 21:10:38 +0000 |
| Subject: | note 14087 added to function.fgets.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15451@lists.php.net to get a copy of this message | ||
to send the result read from a file to the browser without having to wait that all file has been
comitted and the script ended, don't forget to call flush(); often enough, after you echo the
data read by fgets().
Example:
$fp = fopen("filename.html","r");
//or: $fp=fsockopen("www.yoursite.com",80);
//fputs($fp,"GET /index.html HTTP/1.1\r\n");
//fputs($fp,"Host: www.yoursite.com\r\n\r\n");
while (!feof($fp)) {
$answer = fgets($fp,4096);
echo $answer;
//This flush will avoid the user to wait for the whole answer read
//from the $fp file or web site
flush();
}fclose($fp);
http://www.php.net/manual/en/function.fgets.php