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 =)
精彩评论