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中可能用来加密字符串的函数[base64_encode、urlencode、sha1]

登录原理还是蛮复杂的,像我这样以为curl获取页面再post上去的想法真是太单纯了。 整理下遇到的价格处理字符串的函数: 复制代码 代码如下: <?php $encryption...

简介WordPress中用于获取首页和站点链接的PHP函数

home_url()(获取首页链接) ome_url() 函数用来获取 WordPress 的首页链接。 用法 home_url( $path, $scheme ); 参数 $...

php有效防止同一用户多次登录

【问题描述】:同一用户在同一时间多次登录如果不能检测出来,是危险的。因为,你无法知道是否有其他用户在登录你的账户。如何禁止同一用户多次登录呢? 【解决方案】 (1) 每次登录,身份认证成...

PHP严重致命错误处理:php Fatal error: Cannot redeclare class or function

1、错误类型:PHP致命错误 Error type: PHP Fatal error Fatal error: Cannot redeclare (a) (previously decl...

最准确的php截取字符串长度函数

最准确的php截取字符串长度函数

说是最精确截取长度,其实我也不敢确定是否是最精确的,具体有多精确看下面的效果就知道了: 先上测试用的字符串: <?php header("Content-Type:...