Validate URL, Email Address And IP with PHP

Simple PHP functions to validate url, email address and ip.

<?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;
}
 
?>

Source