mb_substr() and substr() work differently
| Bug #28899 | mb_substr() and substr() work differently | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-06-23 21:21 UTC | Modified: | 2005-12-23 12:19 UTC |
|
||||||||||
| From: | mauroi at digbang dot com | Assigned: | hirokawa (profile) | |||||||||||
| Status: | Closed | Package: | mbstring related | |||||||||||
| PHP Version: | 5CVS, 4CVS (2004-12-12) | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-06-23 21:21 UTC] mauroi at digbang dot com
Description:
------------
if I make the following call I get FALSE.
var_dump(substr('', 0));
The documentation says "If string is less than start characters long,
FALSE will be returned".
That can be very ambiguous because start is 0 and the length of the
string is 0 (not less).
Another problem: mb_substr does not work like this. If you overload the
functions and make the same call as above it will return an empty
string.
Thanks in advance.
Reproduce code:
---------------
var_dump(substr('', 0));
var_dump(mb_substr('', 0));
Expected result:
----------------
''
''
Or
FALSE
FALSE
Actual result:
--------------
FALSE
''
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-06-23 22:12 UTC] moriyoshi@php.net
[2004-12-15 04:19 UTC] sniper@php.net
[2004-12-20 10:28 UTC] moriyoshi@php.net
[2004-12-20 13:58 UTC] mauroi at digbang dot com
[2005-02-03 03:25 UTC] sniper@php.net
[2005-02-23 16:56 UTC] drraf at tlen dot pl
[2005-12-21 23:21 UTC] sniper@php.net
[2005-12-23 12:19 UTC] hirokawa@php.net