php下过滤HTML代码的函数

yipeiwu_com6年前PHP代码库

具体如下所示:

/*---------------------- 
过滤HTML代码的函数 
-----------------------*/ 
function htmlEncode($string) { 
  $string=trim($string); 
  $string=str_replace("&","&",$string); 
  $string=str_replace("'","'",$string); 
  $string=str_replace("&","&",$string); 
  $string=str_replace(""",""",$string); 
  $string=str_replace("\"",""",$string); 
  $string=str_replace("&lt;","<",$string); 
  $string=str_replace("<","<",$string); 
  $string=str_replace("&gt;",">",$string); 
  $string=str_replace(">",">",$string); 
  $string=str_replace("&nbsp;"," ",$string); 
  $string=nl2br($string); 
  return $string; 
} 

以上所述是小编给大家介绍的php下过滤HTML代码的函数,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对【宜配屋www.yipeiwu.com】网站的支持!

相关文章

php判断数组元素中是否存在某个字符串的方法

方法一:采用in_array(value,array,type) type 可选。如果设置该参数为 true,则检查搜索的数据与数组的值的类型是否相同。 复制代码 代码如下:$arr...

在PHP中使用curl_init函数的说明

复制代码 代码如下: $ch = curl_init(); $c_url = 'http://www.baidu.com'; $c_url_data = "product_&type="...

php 获得汉字拼音首字母的函数

php获取汉字拼音的第一个字母复制代码 代码如下:<?php function getinitial($str) { $asc=ord(substr($str,0,1)); if...

PHP生成RSS文件类实例

本文实例讲述了PHP生成RSS文件类文件。分享给大家供大家参考。具体如下: PHP RSS 生成类实例代码如下: 复制代码 代码如下:<?php if (defined(...

PHP自动重命名文件实现方法

本文实例讲述了PHP自动重命名文件实现方法。分享给大家供大家参考。具体方法分析如下: PHP重命名文件名我们在实际开发过程中经常会使用到,比如用户上传文件或是一些缓存文件自动生成的功能我...