Integer Regex With mb_ereg_replace()

mb_ereg_replace() used to accept an integer as a regex. It would turn that integer into its equivalent ASCII character and use it as a regex. This behavior has been removed.

A similar change of behavior happened with strpos().

PHP code

<?php

var_dump(mb_ereg_replace(98, 'Z', 'abc'));

?>

Before

PHP Deprecated:  mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /codes/mb_ereg_replaceWithInteger.php on line 3

Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /codes/mb_ereg_replaceWithInteger.php on line 3
string(3) "aZc"

After

string(3) "abc"

PHP version change

This behavior changed in 8.0