note 47942 deleted from function.fgets by betz
| From: | betz@php.net | Date: | Fri, 16 Sep 2005 10:18:37 +0000 |
| Subject: | note 47942 deleted from function.fgets by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-95286@lists.php.net to get a copy of this message | ||
Note Submitter: kevinh at actofmind dot com
Reason: integrated
----
Example 1 goes into an infinite loop if fopen() fails. In my mod_php context, this creates a near
undiagnosable memory black hole. The memory consumption is so severe that it even prevents
transmission of the PHP error messages. May I recommend instead:
<?php
$handle = fopen("/tmp/inputfile.txt", "r");
if($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?>