# Help required to solve the eof() inconsistency across file/memory stream.

- Thread: https://externals.io/message/98336
- Original archive: https://news-web.php.net/php.internals/98336
- Started by Simon JAILLET on 2017-02-22T12:17:14+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #98336 — Simon JAILLET — 2017-02-22T12:17:14+00:00

URL: https://externals.io/message/98336#98336

This is a longstanding issue which is requiring some advanced skills
so I'm begging for some help here.

To sum up the php `feof()` function on memory based streams didn't work
the same way as on file based streams.

On a 10 bytes file eof is setted when 11 bytes is read.
While on a 10 bytes memory stream it requires to 12 bytes to be read
to get the correct eof value.

More details on the issue can be found there:
https://github.com/php/php-src/pull/1153

The source of the problem is related to the fact that the PHP core use
the C read() and `fread()` functions indifferently.

While an attempt of a PR has been made to solve this issue
https://github.com/php/php-src/pull/1578, a complete refactoring of
the feof behavior would probably be a better option here, so that's
why I'm asking for some help/opinions.

Thank you.
