phpdeprecatedereg

Function ereg_replace() is deprecated - How to clear this bug?


I have written following PHP code:

$input="menu=1&type=0&";

print $input."<hr>".ereg_replace('/&/', ':::', $input);

After running above code, it gives following warning,

Deprecated: Function ereg_replace() is deprecated

How can I resolve this warning.


Solution

  • Switch to preg_replaceDocs and update the expression to use preg syntax (PCRE) instead of ereg syntax (POSIX) where there are differencesDocs (just as it says to do in the manual for ereg_replaceDocs).