note 25853 added to function.header
| From: | cwcs at rack1 dot php dot net | Date: | Tue, 08 Oct 2002 23:11:26 +0000 |
| Subject: | note 25853 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37819@lists.php.net to get a copy of this message | ||
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);
--
http://www.php.net/manual/en/function.header.php
http://master.php.net/manage/user-notes.php?action=edit+25853
http://master.php.net/manage/user-notes.php?action=delete+25853
http://master.php.net/manage/user-notes.php?action=reject+25853