Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > note 42130 rejected from function.feof by didou
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 4th January 02:01
didou
External User
 
Posts: 1
Default note 42130 rejected from function.feof by didou



Note Submitter: mark at newfangled dot com

----

When a fopen() is done on a file that has permissions that are set to
not allow the current process user to read it or the file doesn't exist
it returns false. This is expected. The problem is when feof() is fed
the invalid handle it doesn't return TRUE() thus creating an infinite
loop in the following code example.

<?php
$fp = fopen( 't.txt', 'r' );

while( !feof( $fp ) )
{
print fgets( $fp );
}

fclose( $fp );
?>

feof() would return TRUE to cancel the loop and the script would end.
There would of course be warnings because of the invalid file handle,
but that is expected.

There should be better error handling on the developers part and catch
the invalid file handle, but I would expect the file functions to handle
this situation accordingly.
  Reply With Quote


 


Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Php 5 forum, Apache forum, Iis forum, Functions forum, Classes forum, Librarys forum, Bugs forum, Postgres forum, Mysql forum, Paradox forum, Ms sql forum, Configurations forum, Php.ini forum, Problems forum, Scripting forum, Css forum, General forums, Off-topic talk, Links, Extra forums, Php


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666