php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68076 mb_substr() incorrect documentation for length parameter
Submitted: 2014-09-22 18:31 UTC Modified: 2017-07-28 14:59 UTC
From: katrina at pixeldesigns dot ca Assigned: pasindu (profile)
Status: Closed Package: mbstring related
PHP Version: Irrelevant OS: Mac OSX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: katrina at pixeldesigns dot ca
New email:
PHP Version: OS:

 

 [2014-09-22 18:31 UTC] katrina at pixeldesigns dot ca
Description:
------------
---
From manual page: http://www.php.net/function.mb-substr
---

Documentation states: 

length parameter - If omitted or NULL is passed, extract all characters to the end of the string. See here: http://php.net/manual/en/function.mb-substr.php

Ideally omitting NULL would result in a return value of all characters to the end of the string. However, the next best solution would be to update the documentation so that it accurately describes the behaviour of mb_subtr(). 

I have also noticed that other versions of this page do not contain that misleading statement, such as on docs.php.net


Test script:
---------------
mb_substr('Hello I am a string', 6, NULL, 'UTF-8');

RETURNS 'I'

mb_substr('Hello I am a string', 6);

RETURNS 'I am a string'

Expected result:
----------------
mb_substr('Hello I am a string', 6, NULL, 'UTF-8');

RETURNS 'I am a string'

Actual result:
--------------
mb_substr('Hello I am a string', 6, NULL, 'UTF-8');

RETURNS 'I'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-28 17:35 UTC] pasindu@php.net
http://3v4l.org/iEirS seems there was a change between 5.4.7 and 5.4.8 that,
fixed this issues, probably changelog and a example should be added to show this
 [2015-04-28 17:35 UTC] pasindu@php.net
-Assigned To: +Assigned To: pasindu
 [2017-01-28 12:46 UTC] cmb@php.net
-Package: Documentation problem +Package: mbstring related
 [2017-07-28 14:59 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2017-07-28 14:59 UTC] nikic@php.net
Looks like the changelog entry has been added at some point, so closing here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC