PHP Filters are pretty cool, but what do you do if the filters don't quite match what you want? Can you create a custom filter?
filter_var() is a PHP function used to filters a variable with the help of a specified filter. In PHP programming language we can use filter_var() function to validate and sanitize a data such as email id, IP address etc.
Introduction ¶ There are two main types of filtering: validation and sanitization.
The PHP filter_input() function allows you to get an external variable by its name and filter it using one or more built-in filters. The following shows the syntax of the filter_input() function: filter_input ( int $type , string $var_name , int $filter = FILTER_DEFAULT , array|int $options = 0 ) : mixed.
Yes, you can use FILTER_CALLBACK
and provide your own filter function (as callback).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With