strpos() With Integer Argument

strpos() used to accept integer arguments as second argument, $needle. Then, PHP would turn the integer into the equivalent ASCII character, and look for that character.

Since PHP 8.0, it is not the case anymore. If the code requires such behavior, add a call to chr() or mb_chr() to convert the integer to an character, before searching for it.

PHP code

<?php

var_dump(@strpos('abc', 98));

?>

Before

int(1)

After

false

PHP version change

This behavior changed in 8.0

Analyzer