Doc #71892 [NEW]: substr: returns false if len === start, not just len < start
| From: | fredemmott@php.net | Date: | Thu, 24 Mar 2016 17:24:35 +0000 |
| Subject: | Doc #71892 [NEW]: substr: returns false if len === start, not just len < start | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-13341@lists.php.net to get a copy of this message | ||
From: fredemmott
Operating system: n/a
PHP version: 7.0.5RC1
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:substr: returns false if len === start, not just len < start
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 bug report at https://bugs.php.net/bug.php?id=71892&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71892&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71892&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71892&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71892&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71892&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71892&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71892&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71892&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71892&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71892&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71892&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71892&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71892&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71892&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71892&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71892&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71892&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71892&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71892&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71892&r=mysqlcfg