#49038 [Opn->Csd]: Wrong documentation for file_get_contents()
ID: 49038
Updated by: torben@php.net
Reported By: ryan at genius dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2009-09-09 07:31:53] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288188
Log: Noted that the maxlen param is actually not -1 but is instead an
internal value (PHP_STREAM_COPY_ALL) and may not be directly specified
from within a script.
Addresses bug #49038 (although perhaps this is better fixed in the long
term by making file_get_contents() behave normally).
------------------------------------------------------------------------
[2009-07-23 18:59:45] ryan at genius dot com
Description:
------------
The documentation for file_get_contents() is wrong. The default value
of the maxlen param is stated to be -1 but, when looking at the C code,
it is set to PHP_STREAM_COPY_ALL, not -1. Passing -1 will trigger a
warning and return false.
After looking at the C code, the default value is PHP_STREAM_COPY_ALL,
not -1.
Reproduce code:
---------------
$fileContents = file_get_contents('file.txt', 0, null, -1, -1);
Expected result:
----------------
Get the entire file into $fileContents
Actual result:
--------------
Warning: "length must be greater than or equal to zero"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49038&edit=1
Thread (2 messages)