Bug #80336 [Com]: Fatal error: Uncaught ValueError: strrpos(): Argument #3 ($offset) must be con

From: Date: Sun, 08 Nov 2020 17:35:33 +0000
Subject: Bug #80336 [Com]: Fatal error: Uncaught ValueError: strrpos(): Argument #3 ($offset) must be con
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230198@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80336&edit=1 ID: 80336 Comment by: rtrtrtrtrt at dfdfdfdf dot dfd Reported by: info at backups dot nl Summary: Fatal error: Uncaught ValueError: strrpos(): Argument #3 ($offset) must be con Status: Not a bug Type: Bug Package: Strings related Operating System: Ubunutom 20.04 PHP Version: 8.0.0RC3 Assigned To: cmb Block user comment: N Private report: N New Comment: > This requires a lot of code changes and makes things > slower again as we most of the time don not know the > value of the $haystack this is *not* true if/empty are language constructs while strrpos() is an expesnive function call Previous Comments: ------------------------------------------------------------------------ [2020-11-08 17:30:56] info at backups dot nl Hi I must say i am not pleased with this change. Because now we have to check by a if statement if the $haystack NOT is empty before calling any strpos or strrpos or any function that uses a $haystack=false parameter. The php function should do this and just return false not the ones calling the function. This requires a lot of code changes and makes things slower again as we most of the time don not know the value of the $haystack. ------------------------------------------------------------------------ [2020-11-08 15:53:08] cmb@php.net Fine. I'm closing this ticket; please re-open if there is actually an issue with a non-empty string. ------------------------------------------------------------------------ [2020-11-08 13:31:16] info at backups dot nl i will add a check to test the value of $url being empty. Thanks for the hint. ------------------------------------------------------------------------ [2020-11-08 13:26:56] cmb@php.net Are you absolutely sure that $url contains a non-empty value? See <https://3v4l.org/YXmj3>. ------------------------------------------------------------------------ [2020-11-08 12:56:01] info at backups dot nl Description: ------------ Hi I get this fatal error in php 8.0 rc3 Fatal Uncaught ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 Why do i get this error on this code. It is exactly as the php documentation describes to use it. $pos = strrpos($url, '.', -1); Please advice. Test script: --------------- $url='https://myserver.com'; $pos = strrpos($url, '.', -1); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80336&edit=1

« previous php.bugs (#230198) next »