Organizational Research By

Surprising Reserch Topic

function ereg replace is deprecated how to clear this bug


function ereg replace is deprecated how to clear this bug  using -'php,deprecated,ereg'

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.
    

asked Sep 14, 2015 by DewayneEEYsk
0 votes
9 views



Related Hot Questions

3 Answers

0 votes

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).

answered Sep 14, 2015 by ClaudiaWelda
0 votes
print $input."
".ereg_replace('/&/', ':::', $input);

becomes

print $input."
".preg_replace('/&/', ':::', $input);

More example :

$mytext = ereg_replace('[^A-Za-z0-9_]', '', $mytext );

is changed to

$mytext = preg_replace('/[^A-Za-z0-9_]/', '', $mytext );
answered Sep 14, 2015 by LolTolmie
0 votes

http://php.net/ereg_replace says:

Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension.

Thus, preg_replace is in every way better choice. Note there are some differences in pattern syntax though.

answered Sep 14, 2015 by ZitaDechaine

...