[php-src] Issue #8582: Empty string issue for strpos(), strrpos(), stripos(), strripos(), strstr(), strchr(), strrchr(), and stristr()
| From: | dmitrirussu | Date: | Thu, 19 May 2022 15:53:21 +0000 |
| Subject: | [php-src] Issue #8582: Empty string issue for strpos(), strrpos(), stripos(), strripos(), strstr(), strchr(), strrchr(), and stristr() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241542@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8582
Author: dmitrirussu
### Description
Hi following your documentation on php 8.0 I found some incompatibilities, I would like to
understand what is the reason of returning position "0" for empty string when
"$haystack" is not empty... what issue you are solving here?
I would like to argue it is a buggy stuff and nothing more...
The following code:
```php
// let suppose we have next
$haystack = "test";
$needle = "";
$haystack === $needle // => "false" will result in false because $haystack is not
empty string
stripos($haystack, $needle) // => "0" how do you get this :), is "$haystack"
an empty string where is logic, why not keep return "false"
If I do search for empty string then I'm expecting "$haystack" to be empty string....
I'm not expecting you to find a void point on the beginning of string or on end of string,
middle of string...
Could you please provide how many bytes takes empty char into "$haystack =
'test'"? I would say nothing, if nothing then should be false returned
### PHP Version
PHP 8.0
### Operating System
ubuntu