|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76166 file_get_contents reference has an invalid example
Submitted: 2018-03-30 10:24 UTC Modified: 2018-03-30 11:18 UTC
From: zikyky at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Filesystem function related
PHP Version: 7.1.16 OS: Irrelevant
Private report: No CVE-ID: None
 [2018-03-30 10:24 UTC] zikyky at gmail dot com
From manual page:

Example #3 uses "NULL" for a boolean parameter, while this works under normal circumstances, it throws a TypeError if strict_types is enabled.

The example should use FALSE instead of NULL for the $use_include_path parameter, like this:

  $section = file_get_contents('./people.txt', FALSE, NULL, 20, 14);

Test script:
// Read 14 characters starting from the 21st character
$section = file_get_contents('./people.txt', NULL, NULL, 20, 14);

Expected result:
string(14) "lle Bjori Ro" 

Actual result:
Fatal error: Uncaught TypeError: file_get_contents() expects parameter 2 to be boolean, null given in -:4
Stack trace:
#0 -(4): file_get_contents('./people.txt', NULL, NULL, 20, 14)
#1 {main}
  thrown in - on line 4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-30 11:17 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #76166: file_get_contents reference has an invalid example
 [2018-03-30 11:18 UTC]
-Status: Open +Status: Closed -Package: Documentation problem +Package: Filesystem function related -Assigned To: +Assigned To: cmb
 [2018-03-30 11:18 UTC]
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.
 [2020-02-07 06:05 UTC]
Automatic comment on behalf of cmb
Log: Fix #76166: file_get_contents reference has an invalid example
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 02:01:29 2024 UTC