Bug #76814 [Opn->Nab]: file_get_contents fail when maxlen is given null value

From: Date: Thu, 30 Aug 2018 09:49:32 +0000
Subject: Bug #76814 [Opn->Nab]: file_get_contents fail when maxlen is given null value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216804@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76814&edit=1 ID: 76814 Updated by: cmb@php.net Reported by: adrien dot blandin at gmail dot com Summary: file_get_contents fail when maxlen is given null value -Status: Open +Status: Not a bug Type: Bug Package: Filesystem function related Operating System: Debian PHP Version: 7.1.21 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > Signature of file_get_contents is ($filename, $use_include_path > = false, $context = null, $offset = 0, $maxlen = null) Where did you get this idea from? The PHP manual[1] says the signature is: | string file_get_contents ( string $filename [, bool | $use_include_path = FALSE [, resource $context [, int $offset = 0 | [, int $maxlen ]]]] ) So, the $maxlen parameter doesn't have a default; either pass an argument, or not. [1] <http://php.net/manual/en/function.file-get-contents.php> Previous Comments: ------------------------------------------------------------------------ [2018-08-30 08:00:38] adrien dot blandin at gmail dot com Description: ------------ Signature of file_get_contents is ($filename, $use_include_path = false, $context = null, $offset = 0, $maxlen = null) so null is an allowed value for maxlen. Yet, when I explicitly gave the default values in my call: file_get_contents($filename, false, null, 0, null), no content is found. If I call the function with only the filename (so default values will be used too), content is found. If I explicitly gave default values for all parameters except maxlen, content is found. Test script: --------------- echo 'default: ' . strlen(file_get_contents($filename)) . PHP_EOL; echo 'without maxlen: ' . strlen(file_get_contents($filename, false, null, 0)) . PHP_EOL; echo 'with maxlen: ' . strlen(file_get_contents($filename, false, null, 0, null)) . PHP_EOL; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76814&edit=1

« previous php.bugs (#216804) next »