mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
939f764bdc
commit
9785d7ff62
1 changed files with 12 additions and 10 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue