PHP string special symbol filtering method example

Source: Internet
Author: User
I personally think it is good to share an example of a special symbol filtering method in a PHP string. Sometimes you may encounter a php issue of filtering special characters. A method for processing special strings may be omitted. Useful brothers can add them by themselves. Complete code :? Php *** function for filtering special characters * editbywww.jbxue.com * function

I personally think it is good to share an example of a special symbol filtering method in a PHP string. Sometimes you may encounter a php issue of filtering special characters. A method for processing special strings may be omitted. Useful brothers can add them by themselves. Complete code :? Php/*** function for filtering special characters * edit by www.jbxue.com */function

I personally think it is good to share an example of a special symbol filtering method in a PHP string.

Sometimes you may encounter a php issue of filtering special characters. A method for processing special strings may be omitted. Useful brothers can add them by themselves.

Complete code:

 
/**
* Function for filtering special characters

* Edit by www.jbxue.com

*/
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('<', '', $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);return trim($str);}

Articles you may be interested in:

  • Php string filter function example
  • Php Regular Expression Filtering for special characters
  • Php filters out special characters of SQL anti-injection code
  • Php special character filtering example
  • Php practical functions for filtering special characters
  • Html special character filtering php class
  • PHP character string special symbol Filtering Method
  • Php filter parameter special characters anti-Injection
  • Php Method for filtering illegal and special strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.