在PHP中,eregi函数已经在PHP 5.3.0版本中被弃用,并在PHP 7.0.0版本中移除。替代eregi函数的函数是preg_match函数。preg_match函数也可以用来进行正则表达式的匹配,但是在使用时需要使用i修饰符来进行不区分大小写的匹配。例如,preg_match的使用方式如下:
$string = "Hello, World!";
if (preg_match("/hello/i", $string)) {
echo "Match found!";
} else {
echo "Match not found!";
}
上面的代码将会输出Match found!,因为在正则表达式中使用了i修饰符进行不区分大小写的匹配。