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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: spam02 at live dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 12:01:29 2024 UTC