在PHP中,eregi
函數(shù)是用于執(zhí)行不區(qū)分大小寫的正則表達(dá)式匹配的函數(shù)。它與preg_match
函數(shù)類似,但是不區(qū)分大小寫。
例如,以下代碼使用eregi
函數(shù)來檢查一個字符串是否包含"hello"這個單詞(不區(qū)分大小寫):
$string = "Hello, World!";
if (eregi("hello", $string)) {
echo "字符串中包含hello這個單詞";
} else {
echo "字符串中不包含hello這個單詞";
}
在這個例子中,eregi
函數(shù)將會返回true
,因?yàn)樗粎^(qū)分大小寫,所以會匹配到字符串中的"Hello"這個單詞。