#28899 [Opn->Ana]: substr and mb_substr work different
| From: | moriyoshi@php.net | Date: | Wed, 23 Jun 2004 20:12:59 +0000 |
| Subject: | #28899 [Opn->Ana]: substr and mb_substr work different | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-61260@lists.php.net to get a copy of this message | ||
ID: 28899
Updated by: moriyoshi@php.net
Reported By: mauroi at digbang dot com
-Status: Open
+Status: Analyzed
Bug Type: Strings related
Operating System: All
PHP Version: Irrelevant
New Comment:
Good catch. Logically it seems substr() is wrong and mb_substr() is
correct.
Previous Comments:
------------------------------------------------------------------------
[2004-06-23 21:21:51] 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
''
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28899&edit=1