Php – is URL valid or not


Possible Duplicate:
what is the best way to check if a Url exists in PHP ?`

I'm looking for a function that returns TRUE or FALSE in php, either the URL is valid or not.

isValidURL($url); I think that simple… That would take into count all kind of URL possible.

By valid I want it to refer to an existing page of the web or other kind of files. It just should exist.

Best Solution


$url = "http://stack*";

if(filter_var($url, FILTER_VALIDATE_URL) === FALSE)
        echo "Not valid";
        echo "VALID";

this does not check tlds though