php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80952 Against an empty needle it returns [0] instead of [false]
Submitted: 2021-04-12 16:34 UTC Modified: 2021-04-12 16:37 UTC
From: charro at protonmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 8.0.3 OS: Linux
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: charro at protonmail dot com
New email:
PHP Version: OS:

 

 [2021-04-12 16:34 UTC] charro at protonmail dot com
Description:
------------
---
From manual page: https://php.net/function.stripos
---
The function returns [0] instead of [false] if it is searched agains an empty string ''

Prior to PHP 8 the function returned [false]

Test script:
---------------
var_dump( stripos( 'http://example.com', '' ) );

Expected result:
----------------
false

Actual result:
--------------
0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-12 16:37 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2021-04-12 16:37 UTC] nikic@php.net
PHP 8 supports empty needles in string search functions, and no longer treats them as an error condition. For most functions this previously resulted in a warning (https://3v4l.org/jBWnA), stripos() is an exception to that rule.

Noted on https://www.php.net/manual/en/migration80.incompatible.php:

> The needle argument for strpos(), strrpos(), stripos(), strripos(), strstr(), stristr() and strrchr() can now be empty.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 24 00:03:50 2022 UTC