php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zikyky at gmail dot com
New email:
PHP Version: OS:

 

 [2018-03-30 10:24 UTC] zikyky at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.file-get-contents
---

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:
---------------
<?php
declare(strict_types=1);
// Read 14 characters starting from the 21st character
$section = file_get_contents('./people.txt', NULL, NULL, 20, 14);
var_dump($section);
?>

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-30 11:17 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=344590
Log: Fix #76166: file_get_contents reference has an invalid example
 [2018-03-30 11:18 UTC] cmb@php.net
-Status: Open +Status: Closed -Package: Documentation problem +Package: Filesystem function related -Assigned To: +Assigned To: cmb
 [2018-03-30 11:18 UTC] cmb@php.net
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] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=52ac14fb9776027eb61be0a8d124b6711bfa98ec
Log: Fix #76166: file_get_contents reference has an invalid example
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC