kphp
kphp copied to clipboard
[php7.1] Add support for the negative parameter `offset` for `strpos`
In PHP 7.1, function strpos
can accept the negative parameter offset
.
Link: https://www.php.net/manual/ru/function.strpos.php
PHP function
strpos(string $haystack, string $needle, int $offset = 0): int|false
Current behavior
In the implementation, php_warning
is caused when passing a negative number to offset
:
if (offset < 0) {
php_warning("Wrong offset = %" PRIi64 " in function strpos", offset);
return false;
}
Expected behavior
If offset
takes a negative number, then the position of the beginning of the search will be counted from the end of the string.