Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/210961-email-format-validation/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.