
function url_check($buf)
{
$buf=trim($buf);
preg_match("~(?:[a-z0-9-%]+.)+[a-z0-9%]{2,}(:?/[a-z0-9-?%[]=&;#]+)?~i",$buf,$mat); return (isset($mat))?($mat[0]==$buf)?true:false:false;
}
$adres="домен.рф";
$adres=urlencode($adres);
echo (url_check($adres))?"URL VALID!":"URL INVALID!";