Bug #80952 [Opn->Nab]: Against an empty needle it returns [0] instead of [false]

From: Date: Mon, 12 Apr 2021 16:37:31 +0000
Subject: Bug #80952 [Opn->Nab]: Against an empty needle it returns [0] instead of [false]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233374@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80952&edit=1

 ID:                 80952
 Updated by:         nikic@php.net
 Reported by:        charro at protonmail dot com
 Summary:            Against an empty needle it returns [0] instead of
                     [false]
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Strings related
 Operating System:   Linux
 PHP Version:        8.0.3
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2021-04-12 16:34:40] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80952&edit=1


Thread (3 messages)

« previous php.bugs (#233374) next »