2
可能重複:
How can I convert ereg expressions to preg in PHP?轉換eregi功能,PHP 5.3
我如何把這段代碼轉換到PHP 5.3:
if (eregi("VERIFIED",$this->ipn_response)) { }
可能重複:
How can I convert ereg expressions to preg in PHP?轉換eregi功能,PHP 5.3
我如何把這段代碼轉換到PHP 5.3:
if (eregi("VERIFIED",$this->ipn_response)) { }
if (preg_match("/VERIFIED/i",$this->ipn_response)) { }
如果你是尋找像這樣的固定文本你不應該使用正則表達式,因爲它們使用不必要的開銷。
if(stripos('VERIFIED', $this->ipn_response) !== false) { }
這也應該做這項工作。請注意,stripos()
返回您正在查找的字符串的位置,因此它可能會返回零以指示匹配。如果您正在查找的字符串不存在,它將返回布爾值false。
http://php.net/manual/en/reference.pcre.pattern.posix.php – deceze 2011-06-04 04:49:41
這個問題太棒了。 – BoltClock 2011-06-04 04:53:36