Q:

Write a PHP program to valid an email address

0

Write a PHP program to valid an email address.

All Answers

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

<?php
function valid_email($email)
{
  $result = trim($email);
  if (filter_var($result, FILTER_VALIDATE_EMAIL)) 
  {
    return "true";
  } 
  else 
  {
    echo "false";
  }
}
echo valid_email("abc@example.com")."\n";
echo valid_email("abc#example.com")."\n";
?>

Sample Output:

true         
false

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