本帖最后由 gnhao144 于 2011-09-16 12:11:35 编辑

解决方案 »

  1.   


    <?php
    $html='<tr>
          <td align="center">没有可以!</td>';
    if (strpos($html, 'center')){}else{
    echo 'null!';
    }
    ?>
      

  2.   

    能否指点下原理。的确可以解决。不是说没找到反回false莫。
      

  3.   

    对呀,没有找到返回falseif(false == strpos($html,'center'))
    {
         echo '<div class="error_info">不存在!</div>'; exit();
    }!= 是不等于
    == 才是等于
      

  4.   

    <?php
    $html='<tr>
          <td align="center">没有可以!</td>
        
    ';
    header ( 'Content-Type: text/html; charset=gbk'  );
     if(false != strpos($html,'center'))
        {
         echo '<div class="error_info">不存在!</div>'; exit();
        }
    ?>
    红色字里面有空格
    还有你这段程序正确
      

  5.   

    <?php
    $html='<tr>
          <td align="center">没有可以!</td>
        
    ';
    header ( 'Content-Type: text/html; charset=gbk'  );
     if(strpos($html,'center')!==false)
        {
         echo '<div class="error_info">不存在!</div>'; exit();
        }
    ?>
    最好是!==
      

  6.   

    不好意 回错了 
    strpos($html,'center')===false 是不存在centerstrpos($html,'center')!==false 是查找到了‘center’
    <?php
    $html='<tr>
      <td align="center">没有可以!</td>
        
    ';
    header ( 'Content-Type: text/html; charset=gbk' );
     if(strpos($html,'center')===false)
      {
      echo '<div class="error_info">不存在!</div>'; exit();
      }
    ?>
      

  7.   


    if(false != strpos($html,'center'))
    改为:if(strpos($html,'center') === FALSE)这个是PHP手册推荐的标准写法