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);
}

原文链接:https://www.f2er.com/php/25095.html

猜你在找的PHP相关文章