Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 

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 
string(3) "aZc" 

After

string(3) "abc" 

PHP version change

This behavior changed in 8.0.

Extension

© 2023-2026, Damien Seguy - Exakat