Validate Email Address With Regular Expression in PHP

In creating an registration form or feedback form, user has to enter email address on the form which needs to validate manually. If we will not validate for a proper email address, your web form will be the victim of spam registrations. This is a good practice for making the application secure and your data from spams. For checking an email address to be valid or not, you have to check it with the help of a regular expression. It checks whether the email address follows a valid rule or not.

An email id of the form [email protected] is a valid email address.

See the code below.

This was the sample code that will validate the email address and then print whether the email address is valid or not. You can use it a function to return true or false after checking for a valid email address.

PHP also has a built in email validation function. You can also use that function. See the code below:

 

advertisement

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest updates, web design resources and tools.

You have Successfully Subscribed!

About The Author

  • ADD YOUR COMMENT

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Receive fresh web design resources and SEO tips in your email by our weekly newsletter

You have Successfully Subscribed!