PHP if not in string

This question already has an answer here:

  • How do I check if a string contains a specific word? 37 answers

  • I always use this:

    if (stristr($string, "string")) {
        //String exists within $string
    }else{
        //String does not exist
    }
    

    http://www.php.net/stristr


    尝试这个:

    if(strpos($string, 'String') !== false) {
        //string exist
    }
    else{
        //string not exist
    }
    
    链接地址: http://www.djcxy.com/p/13122.html

    上一篇: 如何找到一个变量是否包含某个字符? PHP

    下一篇: PHP如果不在字符串中