tags:

views:

779

answers:

5

Hello, 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.

+1  A: 

Switch to preg_replace and update the expression to use preg syntax instead of ereg syntax where there are differences (just as it says to do in the manual for ereg_replace)

David Dorward
A: 

IIRC they suggest using the preg_ functions instead (in this case, preg_replace).

Wevah
A: 

change the call to ereg_replace to use preg_replace instead

Mark Baker
A: 

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.

Amadan
+1  A: 

Here is more information regarding replacing ereg_replace with preg_replace

Carko