php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80738 Document that mb_stripos() now accepts an empty needle
Submitted: 2021-02-12 13:50 UTC Modified: 2021-02-16 11:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: mikele890 at gmail dot com Assigned:
Status: Verified Package: mbstring related
PHP Version: 8.0.2 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: mikele890 at gmail dot com
New email:
PHP Version: OS:

 

 [2021-02-12 13:50 UTC] mikele890 at gmail dot com
Description:
------------
php < 8:
  var_dump(false === mb_stripos('123456789', ''));
Result:
  <br />
  <b>Warning</b>:  mb_stripos(): Empty delimiter in <b>[...][...]</b> on line    <b>4</b><br />
  bool(true)

php 8:
  var_dump(false === mb_stripos('123456789', ''));
Result:
  bool(false)

In versions lesser than 8 it will throw a warning but return true, which is totally opposite to version 8 result



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-12 14:02 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Package: Unknown/Other Function +Package: mbstring related
 [2021-02-12 14:02 UTC] cmb@php.net
This is only documented in the migration guide[1] so far:

| The needle argument for mb_strpos(), mb_strrpos(), mb_stripos(),
| mb_strripos(), mb_strstr(), mb_stristr(), mb_strrchr() and
| mb_strrichr() can now be empty.

[1] <https://www.php.net/manual/en/migration80.incompatible.php>
 [2021-02-12 14:42 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
the old behavior was simply wrong

think logically: in most cases the second param is dynamic adn an empty string means "no input" - how das it make sense to pretend that *nothing* is within everything?
 [2021-02-15 13:32 UTC] domnulnopcea at gmail dot com
php 8.0.2

var_dump(mb_stripos("test", ""));

int(0)

php 7.4.13

var_dump(mb_stripos("test", ""));

<br />
<b>Warning</b>:  mb_stripos(): Empty delimiter in <b>[...][...]</b> on line <b>5</b><br />
bool(false)


so php 8 returns 0 and php 7 returns false
 [2021-02-16 11:11 UTC] nikic@php.net
-Summary: mb_stipos function +Summary: Document that mb_stripos() now accepts an empty needle
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 15 12:01:23 2021 UTC