|  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
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: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-07-31 11:17 UTC] spam02 at live dot com
seems null = not empty in mb_substr()...
$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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-31 14:38 UTC]
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]
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]
-Status: Open +Status: Wont fix
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 01:01:26 2019 UTC