note 32374 added to function.fgets
| From: | elie at rack1 dot php dot net | Date: | Mon, 26 May 2003 06:22:47 +0000 |
| Subject: | note 32374 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49012@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.fgets.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32374
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32374&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32374&report=yes