note 25853 deleted from function.header by sniper
| From: | sniper@php.net | Date: | Sun, 07 Sep 2003 21:33:41 +0000 |
| Subject: | note 25853 deleted from function.header by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55617@lists.php.net to get a copy of this message | ||
Note Submitter: cwcs at mac dot com
----
The code above for outputting a file is not quite right:
> $fp = fopen($filename, 'r');
> fpassthru($fp); // ** CORRECT **
> fclose($fp);
If you read the documentation for fpassthru it says that after the file has been sent, the file is
closed leaving the file pointer useless. If you then try to close it using fclose, you get a
warning displayed in the browser (and possibly tacked on to the end of your file!). So the correct
algorithm is simply:
$fp = fopen($filename, 'r');
fpassthru($fp);