开发者

How do I check whether the string $_GET["s"] has ++++ in it?

I can also call $_GET["s"] with get_search_query() which outputs a string.

I tried a lot of codes that were supposed to work but 开发者_JAVA技巧none did. Most give true whatever I do. Isn't there a simple way to do this? Thanks


Assuming you mean the literal string "++++"...

if (strpos($_GET['s'], '++++') !== false) {
    // there, do something
} else {
    // not there, do something else
}

Reference: http://php.net/strpos


if( strpos( $_GET['s'], '++++' ) !== false ) {
    // has
} else {
    // doesn't have
}


I'm not sure quite what's troubling you, or if I'm misunderstanding the question, but surely strpos is what you need:

if (strpos($_GET["s"],'++++') !=== false) {
   // the string '++++' was found
}


Edited to fix 'strpos' (nee 'strpoa') typo...oops! With thanks @Jonah Bron =)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜