![]() |
checking email address domains
currently i'm checking with this method:
$email = "godjesus@hotmail.com"; $domain = explode( "@", $email ); if(($domain[1] == "yahoo.com") || ($domain[1] == "hotmail.com")){ echo "its either yahoo or hotmail"; } is there a better way of doing this or is this the most optimized way? |
I don't know what you're after exactly. However, I would put the list of acceptable domains in an array, that way you don't have to keep adding to your if statement. I would take the following approach, using objects so that you can extend if need be, and keep it nice and tidy.
php Code:
Then you would simply use it like so. I've put this in a loop so we can check an array of them. php Code:
|
if your on a linux platform you could use the checkdnsrr() function:
PHP Code:
|
If you want to check domain availability (such as ping the host), try the fsockopen function.
|
| All times are GMT. The time now is 03:22 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0