Doc #76166 [NEW]: file_get_contents reference has an invalid example
| From: | zikyky at gmail dot com | Date: | Fri, 30 Mar 2018 10:24:47 +0000 |
| Subject: | Doc #76166 [NEW]: file_get_contents reference has an invalid example | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-15577@lists.php.net to get a copy of this message | ||
From: zikyky at gmail dot com
Operating system: Irrelevant
PHP version: 7.1.16
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:file_get_contents reference has an invalid example
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
--
Edit bug report at https://bugs.php.net/bug.php?id=76166&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76166&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76166&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76166&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76166&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76166&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76166&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76166&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76166&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76166&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76166&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76166&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76166&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76166&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76166&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76166&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76166&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76166&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76166&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76166&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76166&r=mysqlcfg