What is use of filter_var() function. ?
The filter_var() function filters a variable with the specified filter.
Syntax of filter_var() function
filter_var(var, filtername, options)
You can see below example of array_rand() function in php.
<?php
// $email is a Variable to check
$email = "mac.acc@example.com";
//here call filter_var()
if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
//check email id is valid or not
echo("success!$email is valid");
} else {
echo("error!$email is not valid ");
}
?>
so output will come of above example:
success!mac.acc@example.com is valid
0 Comment(s)