|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49790 mb_substr_count and substr_count do not have the same definition
Submitted: 2009-10-06 15:52 UTC Modified: 2021-01-28 18:56 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: pg dot millon at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: mbstring related
PHP Version: 5.2.11 OS: Ubuntu
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.
Block user comment
Status: Assign to:
Bug Type:
From: pg dot millon at gmail dot com
New email:
PHP Version: OS:


 [2009-10-06 15:52 UTC] pg dot millon at gmail dot com
I'm using the mbstring_funcoverload property defined to 7 which allows the overload of every functions. While using the function substr_count with the 3 parameter (offset) defined. As overloading is activated, calling substr_count is equivalent to calling mb_substr_count but the offset parameter does not exists for this function

Reproduce code:
In php.ini: mbstring.func_overload 7

$var = substr_count('/some/path', DIRECTORY_SEPARATOR, 0);

Expected result:

Actual result:
Warning: mb_substr_count(): Unknown encoding "0" in php shell code on line 1

Call Stack:
    6.0376      46516   1. {main}() php shell code:0
    6.0376      46648   2. mb_substr_count() php shell code:1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-20 09:32 UTC]
-Package: Feature/Change Request +Package: mbstring related
 [2013-03-19 13:07 UTC] neggelandia at gmail dot com
The problem goes deeper. substr_count() takes 4 parameters while mb_substr_count() only takes three (and the third doens't even have the same meaning), which produces errors such as this:

mb_substr_count() expects at most 3 parameters, 4 given

This makes the mbstring.func_overload configuration parameter misbehave.
 [2013-06-09 20:37 UTC] andre at koethur dot de
Without the offset parameter, this function is quite useless, because it will 
behave exact like a binary safe substr_count() with $offset=0. In other words; 
There is only a need for a multi byte aware substr_count when $offset > 0 …
 [2021-01-28 18:56 UTC]
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-01-28 18:56 UTC]
As of PHP 8.0.0, mbstring.func_overload is removed, so this
feature request is obsolete.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 11 05:01:23 2021 UTC