note 32374 deleted from function.fgets by sniper
| From: | sniper@php.net | Date: | Sat, 03 Jan 2004 02:46:08 +0000 |
| Subject: | note 32374 deleted from function.fgets by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62825@lists.php.net to get a copy of this message | ||
Note Submitter: elie at de-brauwer.be
----
It has been my experience that when using fgets on a file have line
lengths that vary from 1 to 3000 that one better supplies the buffer length instead of letting php
do the thinking.
while(! feof($handle)){
$line=fgets($handle);
$crc = crc32(chop($line));
echo $crc . "\n";
}
Which should calculate thet sigend crc32 checksum of each line in a file. When doing this on a file
which contains 10000 lines this should result in a 10000 checksums, this codes delivers more than
15000 checksums, when setting the buffer length to a large enough sice (say 4096), it works fine.
So be carfull with 'letting php do the thinking for you'.
hth
Elie De Brauwer