techtonik Tue Sep 20 08:06:17 2005 EDT
Modified files: /phpdoc/en/reference/filesystem/functions feof.xml Log: + document feof() pitfall if invalid handle passed http://cvs.php.net/diff.php/phpdoc/en/reference/filesystem/functions/feof.xml?r1=1.9&r2=1.10&ty=u Index: phpdoc/en/reference/filesystem/functions/feof.xml diff -u phpdoc/en/reference/filesystem/functions/feof.xml:1.9 phpdoc/en/reference/filesystem/functions/feof.xml:1.10 --- phpdoc/en/reference/filesystem/functions/feof.xml:1.9 Mon Sep 6 15:48:29 2004 +++ phpdoc/en/reference/filesystem/functions/feof.xml Tue Sep 20 08:06:16 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 --> <refentry id="function.feof"> <refnamediv> @@ -26,6 +26,26 @@ </simpara> </warning> &fs.validfp.all; + <warning> + If passed file pointer is not valid you may get an infinite loop, because + EOF fails to return TRUE. + <example> + <programlisting role="php"> + <![CDATA[ +<?php +// if file can not be read or doesn't exist fopen function returns FALSE +$file = @fopen("no_such_file", "r"); + +// FALSE from fopen will issue warning and result in infinite loop here +while (!feof($file)) { +} + +fclose($file); +?> +?]]> + </programlisting> + </example> + </warning> </refsect1> </refentry>