Doc #71892 [Fbk->NoF]: substr: returns false if len === start, not just len < start
| From: | php-bugs at lists dot php dot net | Date: | Sun, 03 Apr 2016 04:22:25 +0000 |
| Subject: | Doc #71892 [Fbk->NoF]: 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-13380@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: php-bugs@lists.php.net
Reported by: fredemmott@php.net
Summary: substr: returns false if len === start, not just len <
start
-Status: Feedback
+Status: No Feedback
Type: Documentation Problem
Package: Strings related
Operating System: n/a
PHP Version: 7.0.5RC1
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2016-03-25 21:43:10] bwoebi@php.net
Note the changelog section:
7.0.0 If string is equal to start characters long, an empty string will be returned. Prior to this
version, FALSE was returned in this case.
------------------------------------------------------------------------
[2016-03-25 01:21:33] requinix@php.net
Sure you're testing with PHP 7? https://3v4l.org/lNZ3N
------------------------------------------------------------------------
[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