svn: /phpdoc/en/trunk/reference/filesystem/functions/ fgetcsv.xml
| From: | Richard Quadling | Date: | Thu, 19 Nov 2009 08:53:30 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/filesystem/functions/ fgetcsv.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5440@lists.php.net to get a copy of this message | ||
rquadling Thu, 19 Nov 2009 08:53:30 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=290968
Log:
Updated return types for invalid file handle. Updated example to include error checking for fopen().
Fix # 50221
Bug: http://bugs.php.net/50221 (Open) fgetcsv error handling
Changed paths:
U phpdoc/en/trunk/reference/filesystem/functions/fgetcsv.xml
Modified: phpdoc/en/trunk/reference/filesystem/functions/fgetcsv.xml
===================================================================
--- phpdoc/en/trunk/reference/filesystem/functions/fgetcsv.xml 2009-11-19 07:07:30 UTC (rev 290967)
+++ phpdoc/en/trunk/reference/filesystem/functions/fgetcsv.xml 2009-11-19 08:53:30 UTC (rev 290968)
@@ -94,8 +94,9 @@
</note>
¬e.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>