Php Filter

The PHP Filter Extension

The PHP filter extension has many of the functions needed for checking user input, and is designed to make data validation easier and quicker. The filter_list() function can be used to list what the PHP filter extension offers:

Sanitize a String

The following example uses the filter_var() function to remove all HTML tags from a string:

Example :-

Result

Hello World!

Validate an Integer

The following example uses the filter_var() function to check if the variable $int is an integer. If $int is an integer, the output of the code below will be: "Integer is valid". If $int is not an integer, the output will be: "Integer is not valid":

Example :-

Result

Integer is valid