Q:

Write a simple PHP program to check that emails are valid

0

Write a simple PHP program to check that emails are valid.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
// pass valid/invalid emails
$email = "mail@example.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) 
{
     echo '"' . $email . '" = Valid'."\n";
}
else 
{
     echo '"' . $email . '" = Invalid'."\n";
}
?>

Sample Output:

"mail@example.com" = Valid

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now