Bug #68481 [Com]: feof true on php://temp one byte early
| From: | tim_siebels_aurich at yahoo dot de | Date: | Sat, 13 Dec 2014 18:07:31 +0000 |
| Subject: | Bug #68481 [Com]: feof true on php://temp one byte early | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189053@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68481&edit=1
ID: 68481
Comment by: tim_siebels_aurich at yahoo dot de
Reported by: tim_siebels_aurich at yahoo dot de
Summary: feof true on php://temp one byte early
Status: Open
Type: Bug
Package: Streams related
Operating System: Tested on Ubuntu
PHP Version: 5.6.3
Block user comment: N
Private report: N
New Comment:
The test script is not correct obviously. The first fopen is supposed to open the file created in
the preceding line.
Previous Comments:
------------------------------------------------------------------------
[2014-11-22 23:14:35] tim_siebels_aurich at yahoo dot de
Description:
------------
To get
feof return true you need to read length+1 bytes you wrote. Or in
general it returns true after you tried to read beyond the last byte.
the php://temp (and php://memory too) stream however returns true after
length bytes read.
Test script:
---------------
<?php
// Test File Stream
$file = tempnam('/tmp', 'feoftest');
$h = fopen("php://temp", 'r+');
fwrite($h, "bug");
fseek($h, 0);
fread($h, 3);
var_dump(feof($h));
// Test Temp Stream
$h = fopen("php://temp", 'r+');
fwrite($h, "bug");
fseek($h, 0);
fread($h, 3);
var_dump(feof($h));
Expected result:
----------------
bool(false)
bool(false)
Actual result:
--------------
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68481&edit=1