<?php
$t= '洗牌完毕 ';
if(mb_strstr($t, '洗牌')){
echo   'mb_strstr发现匹配!';
}else{
echo   'mb_strstr未发现匹配!';
}
?>这样就可以了,第三个参数是需要谨慎调整的!

解决方案 »

  1.   

    你的代码我的调试结果
    mb_strstr未发现匹配!  请按任意键继续. . .
      

  2.   


    <?php 
    $t= '洗牌完毕 '; 
    if(mb_strstr($t, '洗牌 ', 'gbk '))// 请问这里的洗牌后面的空格是什么意思

    echo   'mb_strstr发现匹配! '; 
    }else{ 
    echo   'mb_strstr未发现匹配! '; 

    ?> <?php 
    $t= '洗牌完毕 '; 
    if(strstr($t, '洗牌 '))// 还有这个空格

    echo   'strstr发现匹配! '; 
    }else{ 
    echo   '未发现匹配! '; 

    ?> 
    另外请仔细看手册mb_strstr
    (PHP 5 >= 5.2.0)mb_strstr — Finds first occurrence of a string within anotherDescription
    string mb_strstr ( string $haystack, string $needle [, bool $part [, string $encoding]] )mb_strstr() finds the first occurrence of needle in haystack and returns the portion of haystack. If needle is not found, it returns FALSE. Parametershaystack
    The string from which to get the first occurrence of needle needle
    The string to find in haystack part
    Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the first occurrence of needle. If set to FALSE, it returns all of haystack from the first occurrence of needle to the end, Default value is FALSE. encoding
    Character encoding name to use. If it is omitted, internal character encoding is used. 
    我觉得你有点着急了,没关系的,php有bug是正常的,请提交到 http://bugs.php.net/ 使得更多的同学受益。
      

  3.   

    看看
    string mb_strstr ( string $haystack, string $needle [, bool $part [, string $encoding]] )
    呵呵,你的“gbk”应该是放在第四个参数!
      

  4.   

    试如下代码
    $t= '洗牌完毕';if(mb_strstr($t, '洗牌', false, 'gbk')){ 
    echo   'mb_strstr发现匹配!'; 
    }else{ 
    echo   'mb_strstr未发现匹配!'; 
    }注意参数为true返回的是第一次匹配的位置
      

  5.   

    参数为true返回的是第一次匹配的位置前的字符串。
      

  6.   

    不好意思,发现我每次怀疑是PHP的问题时,最终发现是我自己的问题。
    因为STRSTR函数此时返回的是0,而按布尔值0和FALSE是等价的。
    本人会一如既往的支持PHP,支持我们共同的PHP事业!!!!!!!!!!!!!!!!!!!!!!!!!!11