Doc #71892 [Opn->Fbk]: substr: returns false if len === start, not just len < start

From: Date: Fri, 25 Mar 2016 01:21:34 +0000
Subject: Doc #71892 [Opn->Fbk]: substr: returns false if len === start, not just len < start
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13343@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71892&edit=1 ID: 71892 Updated by: requinix@php.net Reported by: fredemmott@php.net Summary: substr: returns false if len === start, not just len < start -Status: Open +Status: Feedback Type: Documentation Problem -Package: Documentation problem +Package: Strings related Operating System: n/a PHP Version: 7.0.5RC1 Block user comment: N Private report: N New Comment: Sure you're testing with PHP 7? https://3v4l.org/lNZ3N Previous Comments: ------------------------------------------------------------------------ [2016-03-24 17:26:42] fredemmott@php.net The documentation does explicitly describe the empty string as a special case, however it isn't, given the last example, which is not documented. ------------------------------------------------------------------------ [2016-03-24 17:24:33] fredemmott@php.net Description: ------------ "If string is less than start characters long, FALSE will be returned." - 'less than' should be 'less than or equal to' Test script: --------------- <?php var_dump(substr('a', 0, 2)); // string(1) "a" var_dump(substr('', 0, 2)); // bool(false) var_dump(substr('a', 1)); // bool(false) Expected result: ---------------- Based on the documentation, string(1) "a", string(0) "", string(0) "" Actual result: -------------- string(1) "a" bool(false) bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71892&edit=1

« previous php.doc.bugs (#13343) next »