Doc #73132 [NEW]: mb_substr() doesn't always return a string

From: Date: Tue, 20 Sep 2016 18:05:01 +0000
Subject: Doc #73132 [NEW]: mb_substr() doesn't always return a string
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13927@lists.php.net to get a copy of this message
From: greg dot bor at franchisedirect dot com Operating system: irrelevant PHP version: Irrelevant Package: Documentation problem Bug Type: Documentation Problem Bug description:mb_substr() doesn't always return a string Description: ------------ --- From manual page: http://www.php.net/function.mb-substr --- "Return Values" says this returns a string, which is true for most cases but not true for at least one edge case: `var_dump(mb_substr(array(), 0, 1));` returns NULL in PHP 5.3+ (but returns "A" before PHP 5.3). I haven't checked the PHP source, I guess these it can be determined when exactly does mb_substr return NULL. Test results with https://3v4l.org/CuDLX: Output for 5.3.0 - 5.4.45, 5.5.0 - 5.5.34, 5.5.35 - 5.6.26, hhvm-3.10.0 - 3.14.4, 7.0.0 - 7.1.0RC2 ` Warning: mb_substr() expects parameter 1 to be string, array given in /in/CuDLX on line 3 NULL ` Output for 4.3.0 - 5.2.17 ` Notice: Array to string conversion in /in/CuDLX on line 3 string(1) "A" ` Test script: --------------- var_dump(mb_substr(array(), 0, 1)); Expected result: ---------------- The documentation should define when does mb_substr returns NULL. Actual result: -------------- The documentation suggests mb_substr always returns a string. -- Edit bug report at https://bugs.php.net/bug.php?id=73132&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73132&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73132&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73132&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73132&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73132&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73132&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73132&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73132&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73132&r=support Expected behavior: https://bugs.php.net/fix.php?id=73132&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73132&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73132&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73132&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73132&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73132&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73132&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73132&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73132&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73132&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73132&r=mysqlcfg

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