Home > php教程 > php手册 > body text

PHP字符串特殊符号过滤方法示例

WBOY
Release: 2016-06-06 19:45:23
Original
1346 people have browsed it

分享一个PHP字符串中特殊符号的过滤方法的例子,个人感觉还不错哦。 有时会遇到php过滤特殊字符的问题,一个处理特殊字符串的方法,可能有遗漏,有用到的兄弟可以自己补上。 完整代码: ?php /** * 过滤特殊字符的函数 * edit by www.jbxue.com */ function

分享一个PHP字符串中特殊符号的过滤方法的例子,个人感觉还不错哦。

有时会遇到php过滤特殊字符的问题,一个处理特殊字符串的方法,可能有遗漏,有用到的兄弟可以自己补上。

完整代码:

<span><?php </span></span>
Copy after login
<span>/**</span>
Copy after login
<span>* 过滤特殊字符的函数</span>
Copy after login

* edit by  www.jbxue.com

<span>*/</span>
Copy after login
<span>function</span> strFilter(<span>$str</span><span>){
</span><span>$str</span> = <span>str_replace</span>('`', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('·', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('~', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('!', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('!', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('@', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('#', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('$', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('¥', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('%', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('^', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('……', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('&', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('*', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('(', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(')', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('(', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(')', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('-', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('_', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('——', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('+', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('=', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('|', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('\\', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('[', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(']', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('【', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('】', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('{', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('}', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(';', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(';', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(':', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(':', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('\'', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('"', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('“', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('”', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(',', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>(',', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('$str<span>);
</span><span>$str</span> = <span>str_replace</span>('>', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('《', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('》', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('.', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('。', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('/', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('、', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('?', '', <span>$str</span><span>);
</span><span>$str</span> = <span>str_replace</span>('?', '', <span>$str</span><span>);
</span><span>return</span> <span>trim</span>(<span>$str</span><span>);
}</span>
Copy after login

 

您可能感兴趣的文章:

  • php过滤字符串函数示例
  • php正则过滤特殊字符的方法
  • php过滤特殊字符sql防注入代码
  • php特殊字符过滤综合例子
  • php过滤特殊字符实用函数
  • html特殊字符过滤php类
  • PHP字符串特殊符号的过滤方法
  • php过滤参数特殊字符防注入
  • php 过滤非法与特殊字符串的方法
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!