Example 1 — Check That a Filter Exists
Get the list of filter names and check if the email validation filter is in it.
<?php
$filters = filter_list();
echo "Has validate_email: ", in_array('validate_email', $filters, true) ? "yes" : "no", PHP_EOL;
echo "Has int: ", in_array('int', $filters, true) ? "yes" : "no", PHP_EOL; How It Works
- filter_list() returns an array of filter names.
- in_array() checks whether a name appears in that array.
- Both validate_email and int are standard filters, so both are found.
- The true argument makes the comparison strict.

