Return to Snippet

Revision: 65404
at November 28, 2013 21:06 by codingforever99


Initial Code
<?php 
 
function is_valid_url($url){
    $p1 ='/(http|https|ftp):\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i';
    return preg_match($p1, $url); 
}



function is_valid_email($email){
    if (filter_var($email, FILTER_VALIDATE_EMAIL))
        return true;
    else
        return false;
}


function is_valid_ip($ip){
    if (filter_var($ip, FILTER_VALIDATE_IP))
        return true;
    else
        return false;
}

?>

Initial URL
http://function-code.blogspot.com/2013/10/url-email-ip-validation-with-php.html

Initial Description
Simple PHP functions to validate url, email address and ip, functions will return TRUE for valid data and FALSE for invalid data.

Initial Title
url, email and ip validation with php

Initial Tags
email, url, php, validation, ip

Initial Language
PHP