Return to Snippet

Revision: 32764
at November 6, 2012 08:34 by jprochazka


Updated Code
<?php
function validUrl($url) {
    if (preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $url)) {
        return TRUE;
    else
        return FALSE;
    }
}
?>

Revision: 32763
at October 2, 2010 01:37 by jprochazka


Initial Code
<?php

function is_valid_url($url)
{
if (preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $url)) {
    echo "Your url is ok.";
else
    echo "Wrong url.";
}

?>

Initial URL


Initial Description
The following function validates and returns TRUE or FALSE if the supplied string could be a valid domain name format.

Initial Title
Validate a domain name.

Initial Tags
validation

Initial Language
PHP