What to use instead of eregi in PHP?

What to use instead of eregi in PHP?

You can use “preg_match”.

Here is a simple example

1
2
3
4
5
6
7
8
9
$url = 'incvice';
if (preg_match('/incvice/', $url))
 {
echo'match';
 }
else
 {
echo'not match';
 }

So instead of “if (eregi(‘incvice’, $url))”, you just need to put “preg_match” and add those slashes as you see in the example.


Notice that if you try to match weird characters like “&”, it will not work.

On some web scripts, if you use “eregi”, you will get an error that is saying “deprecated”.

Add a comment: