achintha Posted August 17, 2010 Share Posted August 17, 2010 Hi, I need simple function to validate email address format. I have found follwoing function form google. function isemail($email){ return (bool)ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } It's working fine with php < 5.2. But when I'm using with PHP 5.3 is says Deprecated: Function ereg() is deprecated in C:\wamp\www\*******\includes\functions.php on line 28 Is any solution to this without error disable? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/210961-email-format-validation/ Share on other sites More sharing options...
JasonLewis Posted August 17, 2010 Share Posted August 17, 2010 You can use filter_var for this, with the FILTER_VALIDATE_EMAIL filter. Make sure you check out the types of filters as well though. If you want a more portable solution though, this article from Linux Journal is a good read. Quote Link to comment https://forums.phpfreaks.com/topic/210961-email-format-validation/#findComment-1100338 Share on other sites More sharing options...
achintha Posted August 18, 2010 Author Share Posted August 18, 2010 Thanks you sir..... Quote Link to comment https://forums.phpfreaks.com/topic/210961-email-format-validation/#findComment-1100814 Share on other sites More sharing options...
Psycho Posted August 18, 2010 Share Posted August 18, 2010 ProjectFear's solution is fine, but with respect to the error, you should be using preg_match() instead of ereg(). Quote Link to comment https://forums.phpfreaks.com/topic/210961-email-format-validation/#findComment-1100922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.