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
 [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: Wed Nov 13 09:01:29 2024 UTC