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计算百度地图两个GPS坐标之间距离的方法

本文实例讲述了PHP计算百度地图两个GPS坐标之间距离的方法。分享给大家供大家参考。 具体实现方法如下: 复制代码 代码如下:/**  * 计算两个坐标之间的距离(米) &nb...

PHP 正则判断中文UTF-8或GBK的思路及具体实现

UTF-8匹配: 在javascript中,要判断字符串是中文是很简单的。比如: 复制代码 代码如下: var str = "php编程"; if (/^[\u4e00-\u9fa5]+...

PHP基于phpqrcode生成带LOGO图像的二维码实例

本文实例讲述了PHP基于phpqrcode生成带LOGO图像的二维码。分享给大家供大家参考。具体如下: 这里PHP使用phpqrcode生成带LOGO图像的二维码,使用起来很方便,代码中...

PHP中时间加减函数strtotime用法分析

本文实例讲述了PHP中时间加减函数strtotime用法。分享给大家供大家参考,具体如下: 时间加减 <?php //获取本地 提取年份+1 $date=date("Y...

php5数字型字符串加解密代码

<?php /* ----------------------------------------------------------------------------...