开发者

Convert eregi function to php 5.3 [duplicate]

This que开发者_高级运维stion already has answers here: Closed 10 years ago.

Possible Duplicate:

How can I convert ereg expressions to preg in PHP?

How do i convert this code to php 5.3:

if (eregi("VERIFIED",$this->ipn_response)) { }


if (preg_match("/VERIFIED/i",$this->ipn_response)) { }


If you are looking for a fixed text like VERIFIED you shouldn't use regular expressions because they use unnecessary overhead.

if(stripos('VERIFIED', $this->ipn_response) !== false) { }

That should also do the job. Note that stripos() returns the position of the string you are looking for, so it could return zero to indicate a match. It returns boolean false if the string you are looking for is not present.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜