|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-07 05:40 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
feof() is failing to detect the end of file for a file containing a blank file ("\n" character only).
This behaviour is seen on php5 and php6 both.
Reproduce code:
---------------
<?php
$fp = fopen("file2.tmp", "w");
$csv_string = "\n";
fwrite($fp, $csv_string);
fclose($fp);
$fp = fopen("file2.tmp", "r");
var_dump( ftell($fp) );
var_dump( fgetcsv($fp) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
var_dump( fseek($fp, 0, SEEK_END) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
fclose($fp);
?>
Expected result:
----------------
int(0)
array(1) {
[0]=>
string(0) ""
}
int(1)
bool(true)
int(0)
int(1)
bool(true)
Actual result:
--------------
int(0)
array(1) {
[0]=>
string(0) ""
}
int(1)
bool(false)
int(0)
int(1)
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
<?php $fp = fopen("file2.tmp", "w"); $csv_string = "\n"; fwrite($fp, $csv_string); fclose($fp); $fp = fopen("file2.tmp", "r"); var_dump( ftell($fp) ); var_dump( fgetcsv($fp) ); var_dump( ftell($fp) ); var_dump( feof($fp) ); var_dump( fseek($fp, 0, SEEK_END) ); var_dump( ftell($fp) ); var_dump( fgetc($fp) ); var_dump( feof($fp) ); fclose($fp); ?> Gives: int(0) array(1) { [0]=> string(0) "" } int(1) bool(false) int(0) int(1) bool(false) bool(true) And a feof of true. Same result as in 42175? S