|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
21 - 17 = ?
Subscribe to this entry?

 [2021-04-12 16:34 UTC] charro at protonmail dot com
From manual page:
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( '', '' ) );

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-12 16:37 UTC]
-Status: Open +Status: Not a bug
 [2021-04-12 16:37 UTC]
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 (, stripos() is an exception to that rule.

Noted on

> The needle argument for strpos(), strrpos(), stripos(), strripos(), strstr(), stristr() and strrchr() can now be empty.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Apr 01 14:03:38 2023 UTC