Updated return types for invalid file handle. Updated example to include error checking for fopen(). Fix # 50221

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290968 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Richard Quadling 2009-11-19 08:53:30 +00:00
parent 939f764bdc
commit 9785d7ff62

View file

@ -94,8 +94,9 @@
</note>
&note.line-endings;
<para>
<function>fgetcsv</function> returns &false; on error, including end of
file.
<function>fgetcsv</function> returns &null; if an invalid
<parameter>handle</parameter> is supplied or &false; on other errors,
including end of file.
</para>
</refsect1>
@ -144,16 +145,17 @@
<![CDATA[
<?php
$row = 1;
$handle = fopen("test.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}
fclose($handle);
?>
]]>
</programlisting>