Write a php program that tests whether an e-mail address is input correctly
Answers
Answered by
0
urcemenu
share

PHP Exercises : Email validation
Last update on August 27 2018 07:01:07 (UTC/GMT +8 hours)
PHP : Exercise-12 with Solution
Write a simple PHP program to check that emails are valid.
Hints : Use FILTER_VALIDATE_EMAIL filter that validates value as an e-mail address.
Note : The PHP documentation does not say that FILTER_VALIDATE_EMAIL should pass the RFC5321.
Sample Solution: -
PHP Code:
<?php // pass valid/invalid emails $email = "[email protected]"; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '"' . $email . '" = Valid'."\n"; } else { echo '"' . $email . '" = Invalid'."\n"; } ?>
share

PHP Exercises : Email validation
Last update on August 27 2018 07:01:07 (UTC/GMT +8 hours)
PHP : Exercise-12 with Solution
Write a simple PHP program to check that emails are valid.
Hints : Use FILTER_VALIDATE_EMAIL filter that validates value as an e-mail address.
Note : The PHP documentation does not say that FILTER_VALIDATE_EMAIL should pass the RFC5321.
Sample Solution: -
PHP Code:
<?php // pass valid/invalid emails $email = "[email protected]"; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '"' . $email . '" = Valid'."\n"; } else { echo '"' . $email . '" = Invalid'."\n"; } ?>
Similar questions