分享一个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>