How do check whether the valid email address or not in PHP?; In this post, I will teach you how to check valid emails from the string or incoming requests. The function will return a boolean if the email address is valid or return a false if not valid.
Using PHP filter_var() function you can easy to validate your email address whether in the given email "@" available and "." available in the given email address string. Having read this tutorial you will easy to check valid email address from the given input.
For This valid email check-in PHP, we will pass two arguments in this function. In the first argument, we will pass the input string, and the second argument we will pass the type of check to use.
The following example uses the filter_var function, First, we will sanitize and remove all illegal characters from the $email variable, then we will check if it is a valid email address of not.
How To Check Given URL Is Valid Or Not PHP Function Example
<?php
$email = "haresh@example.com";
// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate e-mail
if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
echo("$email is a valid email address");
} else {
echo("$email is not a valid email address");
}
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- How Do Check Whether The Email Address Valid Email Or Not In PHP Example
- Timestamp convert to datetime format
- Get Full Address From Latitude Longitude Google Map API In PHP
- Simple WhatsApp Messages Send Using Chat API In PHP
- Zoom API Integration with PHP
- PHP Post Request cURL Example With Authentication
- How To Get Youtube Video Thumbnail From URL In PHP - Laravel
- Php Questions for Interview
- UPI Payment Gateway Integration in PHP/Laravel
- Create Database In MYSQL Using PHP Script Example