php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62703 substr() length=null
Submitted: 2012-07-31 11:17 UTC Modified: 2012-08-01 02:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: spam02 at live dot com Assigned:
Status: Wont fix Package: Strings related
PHP Version: 5.3.15 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-07-31 11:17 UTC] spam02 at live dot com
Description:
------------
seems null = not empty in mb_substr()...
//example
$text = 'test';

mb_substr($text,-1);  //result t
mb_substr($text,-1,null) //result '' expected t
substr($text,-1); //result t
substr($text,-1, null) //result '' expected t
php version 5.3.3-7+squeeze13


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-31 14:38 UTC] laruence@php.net
yeah, null also can be considered as 0, so, this is a little confused. the fix 
will be easy, however fixing this might introduce bc break(not sure)
 [2012-08-01 02:00 UTC] aharvey@php.net
This is documented behaviour: if the length parameter weakly evaluates to int(0), false, null or an empty string may be returned. We can't fix this without a BC break, and I don't think it's worth it, personally.
 [2012-08-01 02:00 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 15:01:54 2014 UTC