Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use filter_var() function in php.?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 154
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: