Home > Backend Development > PHP Tutorial > How to filter special symbols in PHP strings

How to filter special symbols in PHP strings

PHP中文网
Release: 2016-07-25 08:54:17
Original
2173 people have browsed it

PHP字符串特殊符号的过滤方法 :

有时候我们会遇到过滤字符串中特殊字符的问题,本文提供了一个处理特殊字符串的方法,可能有遗漏,如果读者发现了可以留言告诉我,谢谢。

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 = 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(&#39;<&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;>&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;《&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;》&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;.&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;。&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;/&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;、&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;?&#39;, &#39;&#39;, $str);
    $str = str_replace(&#39;?&#39;, &#39;&#39;, $str);
    return trim($str);
}
Copy after login

以上就是PHP字符串特殊符号的过滤方法 的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template