php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34183 feof() doesn't work within a class
Submitted: 2005-08-18 10:48 UTC Modified: 2005-08-18 13:07 UTC
From: osmium at 163 dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.1.0b3 OS: Windows 2003, Windows 2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: osmium at 163 dot com
New email:
PHP Version: OS:

 

 [2005-08-18 10:48 UTC] osmium at 163 dot com
Description:
------------
When using fseek() to specify an offset larger than or equal to the file size, function feof() could not identify the EOF flag either in a class method or a function, it always return FALSE. But it works outside functions and classes.

There are same problems in version 4.3.11, 4.4.0 and 5.0.4

Reproduce code:
---------------
<?php
class FileHandler
{
	var $handle = null;
	function eof($file, $pos) {
		$this->handle = fopen($file, "r");
		fseek($this->handle, $pos);
		echo "Is EOF: ", (feof($this->handle)) ? "YES" : "NO";
	}
	
	function eof2($file, $pos) {
		$handle = fopen($file, "r");
		fseek($handle, $pos);
		echo "Is EOF: ", (feof($handle)) ? "YES" : "NO";
	}
}

function eof3($file, $pos) {
	$handle = fopen($file, "r");
	fseek($handle, $pos);
	echo "Is EOF: ", (feof($handle)) ? "YES" : "NO";
}
// my file has 32 chars only
$handler = new FileHandler();
$handler->eof($file, 320);
$handler->eof2($file, 320);
eof2($file, 320);
?>

Expected result:
----------------
Is EOF: YES
Is EOF: YES
Is EOF: YES

Actual result:
--------------
Is EOF: NO
Is EOF: NO
Is EOF: NO

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-18 13:07 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC