可能重复:
如何在PHP中将ereg表达式转换为preg?
如何将此代码转换为php5.3:
if (eregi("VERIFIED",$this->ipn_response)) { }
if (preg_match("/VERIFIED/i",$this->ipn_response)) { }
如果您正在寻找像VERIFIED
这样的固定文本,则不应该使用正则表达式,因为它们会使用不必要的开销。
if(stripos('VERIFIED', $this->ipn_response) !== false) { }
这也应该起作用。注意,stripos()
返回您要查找的字符串的位置,因此它可以返回零来表示匹配。如果您要查找的字符串不存在,则返回布尔值false。