VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > PHP >
  • php过滤所有HTML标记

文章为你提供二款php 过滤所有HTML标记,他可以过滤所有的html标签啊,去除html标记,代码如下:

  1. function text2html($txt){ 
  2.         $txt = str_replace("  "," ",$txt); 
  3.         $txt = str_replace("<","&lt;",$txt); 
  4.         $txt = str_replace(">","&gt;",$txt); 
  5.         $txt = preg_replace("/[ ]{1,}/isu","<br/> ",$txt); 
  6.         return $txt

清除html标记,代码如下:

  1. function clearhtml($str){ 
  2.         $str = str_replace('<','&lt;',$str); 
  3.         $str = str_replace('>','&gt;',$str); 
  4.         return $str; 
  5. }//开源软件:phpfensi.com
  6.  

出处:http://www.phpfensi.com/php/20140919/5723.html


相关教程