#49939 [Opn->Ana]: iconv_substr() misbehaves when length parameter set to 0
| From: | jani@php.net | Date: | Wed, 21 Oct 2009 10:24:43 +0000 |
| Subject: | #49939 [Opn->Ana]: iconv_substr() misbehaves when length parameter set to 0 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2983@lists.php.net to get a copy of this message | ||
ID: 49939
Updated by: jani@php.net
Reported By: ladislav at marek dot su
-Status: Open
+Status: Analyzed
-Bug Type: ICONV related
+Bug Type: Documentation problem
Operating System: *
PHP Version: 5.*, 6
New Comment:
It's just a bug in the docs. iconv_substr() behaves exactly same way as
substr() does with same parameters.
Previous Comments:
------------------------------------------------------------------------
[2009-10-21 08:32:58] ladislav at marek dot su
Description:
------------
According to documentation and reflection: iconv_substr has third
argument $length, default value is 0, but iconv_substr returns different
result when argument is not passed and when argument is passed as zero.
(Now it's not possible to call iconv_substr with $charset argument and
preserve correct behaviour.)
Reproduce code:
---------------
var_dump(iconv_substr('foobar', 3)); // "bar"
var_dump(iconv_substr('foobar', 3, 0)); // ""
var_dump(iconv_substr('foobar', 3, NULL, 'UTF-8')); // ""
Expected result:
----------------
string(3) "bar"
string(0) "bar"
string(0) "bar"
Actual result:
--------------
string(3) "bar"
string(0) ""
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49939&edit=1