i

PHP Tutorial

PHP Sanitization Filters

There are many filters for sanitization as below:

  • FILTER_SANITIZE_EMAIL – It removes all characters except letters, digits and !#$%^&*_+=.{|}~@.[].

  • FILTER_SANITIZE_NUMBER_FLOAT – It removes all characters except digits, +- and .,eE.

  • FILTER_SANITIZE_NUMBER_INT – It removes all characters except digits, +-.

  • FILTER_SANITIZE_URL – It removes all characters except letters, digits and $-_+!*’(),{}|\\^~[]`<>#%”;/?:@&=.

  • FILTER_SANITIZE_ENCODED – It removes or encodes the special characters.

  • FILTER_SANITIZE_MAGIC_QUOTES – It apply addslashes().

  • FILTER_SANITIZE_SPECIAL_CHARS – It removes special characters.

  • FILTER_SANITIZE_STRING – It removes tags/special characters from a string.

  • FILTER_SANITIZE_STRIPPED – It also does the same function as the sanitize string function.