|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46426 3rd parameter offset of stream_get_contents not works for "0"
Submitted: 2008-10-30 08:15 UTC Modified: 2010-02-17 00:23 UTC
From: zhustar at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID:
 [2008-10-30 08:15 UTC] zhustar at gmail dot com
php 5.2.0
I want get the string from begin to the end ("12345")
but return empty when set offset to 0

Reproduce code:
$tmp = tmpfile();
fwrite($tmp, "12345");
echo "---\n";
echo stream_get_contents($tmp, -1, 0);
echo "\n";
echo stream_get_contents($tmp, -1, 1);
echo "\n";
echo stream_get_contents($tmp, -1, 2);
echo "\n---";

Expected result:

Actual result:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-30 10:13 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

We need add a note in the documentation.
 [2010-02-17 00:23 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Nothing to document here.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 03:01:32 2015 UTC