|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76303 file_get_contents - 4th parameter default was -1 now its 0
Submitted: 2018-05-06 13:55 UTC Modified: 2018-05-06 14:02 UTC
From: roland at inkoeln dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.2.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: roland at inkoeln dot com
New email:
PHP Version: OS:


 [2018-05-06 13:55 UTC] roland at inkoeln dot com
From manual page:
in php 5.x upto 7.0.x

file_get_contents('merge.json', false, null, -1); 

returns complete file content

in PHP 7.2.3-1ubuntu1 (cli) (built: Mar 14 2018 22:03:58) ( NTS )

file_get_contents('merge.json', false, null, -1);

return only last character (\n)

This breaks backward compatibility for me

Test script:

print file_get_contents('some_file.txt', false, null, -1);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-06 14:02 UTC]
-Status: Open +Status: Not a bug
 [2018-05-06 14:02 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

This particular behavior is documented in at least three locations so there's no reason to not know about it.
Besides, passing the default values for trailing arguments is silly. Don't do that.
 [2018-05-06 23:30 UTC] a at b dot c dot de
Why were you passing a negative number for the offset in PHP 5 to begin with?
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 12:01:27 2021 UTC