Rumah  >  Artikel  >  php教程  >  PHP字符串特殊符号过滤方法示例

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

WBOY
WBOYasal
2016-06-06 19:45:231348semak imbas

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

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

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

完整代码:

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

* edit by  www.jbxue.com

<span>*/</span>
<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>

 

您可能感兴趣的文章:

  • php过滤字符串函数示例
  • php正则过滤特殊字符的方法
  • php过滤特殊字符sql防注入代码
  • php特殊字符过滤综合例子
  • php过滤特殊字符实用函数
  • html特殊字符过滤php类
  • PHP字符串特殊符号的过滤方法
  • php过滤参数特殊字符防注入
  • php 过滤非法与特殊字符串的方法
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:PHP在GB2312编码下截断字符串Artikel seterusnya:php linux 环境搭建