加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

PHP字符串中特殊符号的过滤方法介绍

发布时间:2020-05-24 10:38:17 所属栏目:PHP 来源:互联网
导读:本篇文章主要是对PHP字符串中特殊符号的过滤方法进行了详细的介绍,需要的朋友可以过来参考下,希望对大家有所帮助

有时候我们会遇到过滤字符串中特殊字符的问题,本文提供了一个处理特殊字符串的方法,可能有遗漏,如果读者发现了可以留言告诉我,谢谢。
<div class="codetitle"><a style="CURSOR: pointer" data="23441" class="copybut" id="copybut23441" onclick="doCopy('code23441')"> 代码如下:<div class="codebody" id="code23441">
function strFilter($str){
$str = str_replace('`','',$str);
$str = str_replace('·',$str);
$str = str_replace('~',$str);
$str = str_replace('!',$str);
$str = str_replace('!',$str);
$str = str_replace('@',$str);
$str = str_replace('#',$str);
$str = str_replace('$',$str);
$str = str_replace('¥',$str);
$str = str_replace('%',$str);
$str = str_replace('^',$str);
$str = str_replace('……',$str);
$str = str_replace('&',$str);
$str = str_replace('*',$str);
$str = str_replace('(',$str);
$str = str_replace(')',$str);
$str = str_replace('(',$str);
$str = str_replace(')',$str);
$str = str_replace('-',$str);
$str = strreplace('',$str);
$str = str_replace('——',$str);
$str = str_replace('+',$str);
$str = str_replace('=',$str);
$str = str_replace('|',$str);
$str = str_replace('',$str);
$str = str_replace('[',$str);
$str = str_replace(']',$str);
$str = str_replace('【',$str);
$str = str_replace('】',$str);
$str = str_replace('{',$str);
$str = str_replace('}',$str);
$str = str_replace(';',$str);
$str = str_replace(';',$str);
$str = str_replace(':',$str);
$str = str_replace(':',$str);
$str = str_replace(''',$str);
$str = str_replace('"',$str);
$str = str_replace('“',$str);
$str = str_replace('”',$str);
$str = str_replace(',',$str);
$str = str_replace(',',$str);
$str = str_replace('<',$str);
$str = str_replace('>',$str);
$str = str_replace('《',$str);
$str = str_replace('》',$str);
$str = str_replace('.',$str);
$str = str_replace('。',$str);
$str = str_replace('/',$str);
$str = str_replace('、',$str);
$str = str_replace('?',$str);
$str = str_replace('?',$str);
return trim($str);
}

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读