#49939 [Ana->Csd]: iconv_substr() misbehaves when length parameter set to 0
| From: | vrana@php.net | Date: | Fri, 13 Nov 2009 19:48:47 +0000 |
| Subject: | #49939 [Ana->Csd]: iconv_substr() misbehaves when length parameter set to 0 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3118@lists.php.net to get a copy of this message | ||
ID: 49939
Updated by: vrana@php.net
Reported By: ladislav at marek dot su
-Status: Analyzed
+Status: Closed
Bug Type: Documentation problem
Operating System: *
PHP Version: 5.*, 6
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Default is strlen($str).
Previous Comments:
------------------------------------------------------------------------
[2009-11-13 19:48:31] svn@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=290687
Log: Length default (bug #49939)
------------------------------------------------------------------------
[2009-10-21 10:24:43] jani@php.net
It's just a bug in the docs. iconv_substr() behaves exactly same way as
substr() does with same parameters.
------------------------------------------------------------------------
[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