DWQA QuestionsHow do you use filter_sanitize_EMAIL in PHP?
Tamil Amuthan Staff asked 4 years ago

The FILTER_SANITIZE_EMAIL filter removes all illegal characters from an email address.

Remove all illegal characters from an email address:

Example:

<?php
// Variable to check
$email = “john(.doe)@exa//mple.com”;

// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);

echo $email;
?>

Output:

john.doe@example.com