$content=str_replace('<script','&lt;script',$_POST['content']);
$content=str_replace('<?','&lt;?',$content);
$content=str_replace('script>','script&gt;',$content);
$content=str_replace('?>','?&gt;',$content);
$content=str_replace('"','&quot;',$content);
$content=str_replace("'",'&#039;',$content);
$content=str_replace("&",'&amp;',$content);应该没了吧???主要是我要允许<font size=6>   <font color>之类的通过,其他的特殊符号要转义

解决方案 »

  1.   

    htmlspecialchars($_POST['content']);  //把预定义字符实体化不就可以了
      

  2.   

    htmlspecialchars($_POST['content'], ENT_NOQUOTES)
      

  3.   


    <?php
    $a="<font size=6>123</font>";
    echo htmlspecialchars($a, ENT_NOQUOTES);
    ?>试试,错了~~~
      

  4.   

    其实你是怕xss攻击吧?
    找个完整的带过滤代码的框架(例如ci什么的),把对应内容扒下来就行了