首頁 > php教程 > php手册 > 主體

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

WBOY
發布: 2016-06-06 19:45:23
原創
1340 人瀏覽過

分享一个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 过滤非法与特殊字符串的方法
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!