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
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: 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: Sun May 05 10:01:31 2024 UTC