str_pos() Requires Only Strings

Until PHP 8.0, str_pos() accepted integers as second argument, and would convert them into their equivalent ASCII char. This was a hidden feature of PHP.

Since PHP 8.0, the integer is converted to string as is, and used for the search.

PHP code

<?php

var_dump(strpos('abc ', 32));

?>

Before

PHP Deprecated:  strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
int(3)

After

bool(false)

PHP version change

This behavior changed in 8.0

Error Messages

Analyzer