如何在PHP中去除代码中所有的html标签。
用正则去除英文的方法就不必说了!

解决方案 »

  1.   

    利用strip_tags()就可以把html标签去除掉.
      

  2.   

    就是楼上说的方法。可参考http://www.w3school.com.cn/php/func_string_strip_tags.asp
      

  3.   

    strip_tags()会去掉标签
    htmlspecialchars()则会将<>转为 &lt; &gt;
      

  4.   

    <?php 
    function html2txt($document){ 
    $search = array('@<script[^>]*?>.*?</script>@si',  // Strip out javascript 
                   '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags 
                   '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly 
                   '@<![\s\S]*?--[ \t\n\r]*>@'         // Strip multi-line comments including CDATA 
    ); 
    $text = preg_replace($search, '', $document); 
    return $text; 

    ?>