How to validate a variable is Email in Php?
In this post, This function checks whether a variable is email address or not. Email address validator.
1. Code:
<?php function checkIsEmail($var){ return false !== filter_var($var, FILTER_VALIDATE_EMAIL); } var_dump(checkIsEmail("soltuts.com")); echo "<br>"; var_dump(checkIsEmail("soltuts@gmail.com")); ?>
2. Example:
Input:
Input: "soltuts.com" Input: "soltuts@gmail.com"
Output:
Output: false Output: true