An email address can be validated using php code. PHP web developers need to validate the email address for contact us, registration, profile, login form page etc in website. Email address should be in correct form. So Form data submitted by user will send correctly in email.
Validating email on the server side is a more secure way than validating it on the client side.
How to validate email address using php code?
We can use php function filter_var() with FILTER_VALIDATE_EMAIL to validate emails.
Please look ate the example code for validating email address.
return filter_var($email, FILTER_VALIDATE_EMAIL);
echo "Your Email address is valid.";
echo "Sorry, Your Email address is invalid!";
Your Email address is valid.
Also We can also use below php function preg_match() for validating email address using the below regular expression pattern.