$email = "example@email.com"; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "Invalid email format"; }
$name = $_POST['name']; $sanitized_name = filter_var($name, FILTER_SANITIZE_STRING);This example uses the filter_var() function to sanitize user input by removing any potentially dangerous characters. Package Library: PHP User Format is a built-in PHP library and does not require any external package to be installed. It is available in all versions of PHP.