|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-22 18:51 UTC] cellog@php.net
Description:
------------
in 5.0.4, if stream_eof() returns false, feof() returns true, in 5.1.0b3, if stream_eof() returns true, feof() returns true.
In addition to the small test below, a slightly larger real-world streams test is available in cvs at pear/PHP_Archive/tests/eof.phpt
Reproduce code:
---------------
<?php
class Mystream
{
static $a = false;
function stream_open()
{
return true;
}
function stream_eof()
{
var_dump(self::$a);
return self::$a;
}
function stream_seek()
{
return true;
}
function stream_tell()
{
return 0;
}
}
stream_wrapper_register('testing', 'Mystream');
$fp = fopen('testing://blah', 'r');
var_dump(1, feof($fp));
fseek($fp, 100);
Mystream::$a = true;
var_dump(2, feof($fp));
?>
Expected result:
----------------
bool(false)
int(1)
bool(true)
bool(true)
int(2)
bool(false)
Actual result:
--------------
bool(false)
int(1)
bool(false)
bool(true)
int(2)
bool(true)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 05:00:01 2025 UTC |
since there has been some question of the brilliance of the test script on irc, I will provide one that appeals to the objectors <?php class Mystream { private $snobs = 0; function stream_open() { return true; } function stream_eof() { var_dump($this->snobs); return !($this->snobs >= 99); } function stream_seek($a) { $this->snobs = $a; return true; } function stream_tell() { return $this->snobs; } } stream_wrapper_register('testing', 'Mystream'); $fp = fopen('testing://blah', 'r'); var_dump(1, feof($fp)); fseek($fp, 100); Mystream::$a = true; var_dump(2, feof($fp)); ?>