note 17355 deleted from function.fgets by jimw

From: Date: Thu, 20 Dec 2001 21:22:23 +0000
Subject: note 17355 deleted from function.fgets by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23436@lists.php.net to get a copy of this message
We have seen the correct way to test for feof in a few posts above: $buffer = fgets ($fp) while (!feof ($fp)) { //code code.. blah //code here.. $buffer = fgets ($fp) } But I have been just testing the return value of fgets: while ($buffer = fgets ($fp)) { // Code code... } Since fgets returns FALSE when no data has been read you can be certain you wont make a pass through your logic with an empty buffer. I haven't had any problems doing this and as far as I can tell it's a cleaner way of handling things.

« previous php.notes (#23436) next »