Last active
May 25, 2021 11:40
-
-
Save byeblogs/aea50c9f8e038eebc9f9f68bef2d9f10 to your computer and use it in GitHub Desktop.
Check Validasi Email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php header("Content-Type: text/plain"); | |
| function cekValidEmail($email) { | |
| if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | |
| list($user, $host) = explode('@', $email); | |
| if (!checkdnsrr($host, 'MX')) { | |
| return false; | |
| } else { | |
| return true; | |
| } | |
| } else { | |
| return false; | |
| } | |
| } | |
| $email = array( '[email protected]', | |
| '[email protected]', | |
| '[email protected]' | |
| ); | |
| foreach ($email as $mail) { | |
| if(cekValidEmail($mail)) { | |
| echo($mail . " {Email Valid}" . PHP_EOL . PHP_EOL); | |
| } else { | |
| echo($mail . " {Email tidak Valid!}" . PHP_EOL . PHP_EOL); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment