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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 10:01:27 2024 UTC