Doc #71892 [Com]: substr: returns false if len === start, not just len < start

From: Date: Thu, 24 Mar 2016 17:26:43 +0000
Subject: Doc #71892 [Com]: 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-13342@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 Comment by: fredemmott@php.net Reported by: fredemmott@php.net Summary: substr: returns false if len === start, not just len < start Status: Open Type: Documentation Problem Package: Documentation problem Operating System: n/a PHP Version: 7.0.5RC1 Block user comment: N Private report: N New Comment: The documentation does explicitly describe the empty string as a special case, however it isn't, given the last example, which is not documented. Previous Comments: ------------------------------------------------------------------------ [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 (#13342) next »