Bug #80339 [Dup]: fatal error on calling strrpos
| From: | nikic@php.net | Date: | Sun, 08 Nov 2020 19:40:50 +0000 |
| Subject: | Bug #80339 [Dup]: fatal error on calling strrpos | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230206@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80339&edit=1
ID: 80339
Updated by: nikic@php.net
Reported by: info at backups dot nl
Summary: fatal error on calling strrpos
Status: Duplicate
Type: Bug
Package: *General Issues
Operating System: ubuntu server
PHP Version: 8.0.0RC3
Block user comment: Y
Private report: N
New Comment:
Don't think there's much point in taking this to the mailing list, I doubt the resolution
is going to change. Out of bounds indexes have always been considered an error condition for
strpos-style functions (see for example https://3v4l.org/30HoR). These error conditions have become
exceptions in PHP 8 in line with general guidelines.
strrpos() in particular did not throw a warning before due to an implementation oversight --
however, this has been fixed in PHP 8 as the treatment of strpos() and strrpos() must be the same
for obvious consistency reasons.
Previous Comments:
------------------------------------------------------------------------
[2020-11-08 18:49:24] girgias@php.net
Please discuss this on the internals mailing list instead of opening duplicate bug reports.
------------------------------------------------------------------------
[2020-11-08 18:48:03] info at backups dot nl
Description:
------------
I get a fatal error on calling strrpos when the haystack is empty. I now have to check the haystack
before calling strrpos,
$haystack='';
$pos = strrpos($haystack, '.', -1);
May other issue was brutally closed for replies. https://bugs.php.net/bug.php?id=80336
I don't understand why as the last answer given by you is incorrect.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80339&edit=1