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.
<?php
function check_email($email)
{
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
if(check_email("[email protected]")){
echo "Your Email address is valid.";
}else{
echo "Sorry, Your Email address is invalid!";
}
?>
Output :
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.
preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email);
seo services edmonton
Looking to boost your online presence? Our SEO services in Edmonton specialize in tailored strategies to improve your website's visibility and drive organic traffic. From keyword research to on-page optimization, we help local businesses achieve top rankings and connect with their target audience effectively. Elevate your digital marketing today!
https://digitalmonkseo.ca/edmonton-seo/