parse_url() can only break the url into several parts, but it can't check whether an url is workable. What's the function to check whether an url is valid?
What do you mean with "is workable"? Do you want to verify if an URL exists, meaning, if it's online and accessible? If that's the case, have a look at this topic. If you want to verify if an URL is in a valid format, you can use a regular expression, such as: function is_valid_url($url) { return preg_match('/^ (ht|f)tps?:\/\/ # scheme ([a-z0-9][a-z0-9-\.]*[a-z0-9]\.)? # www or subdomain (optional) [a-z0-9][a-z0-9-]*[a-z0-9] # domain \.[a-z]{2,4} # extension (:\d{2,4})? # port (optional) \/[\w-\.~!\*\'\(\);:@&= # path \+\$,\/\?%\[\]]+ # path (continued) (\#[\w-\s]+)? # anchor (optional) $/xi', $url); } PHP: Usage example: $url = 'http://www.google.co.uk:80/url?sa=t&ct=res&cd=2&url=http%3A%2F%2Fwww.spanish-teaching.com%2Fblog%2F_archives%2F2007%2F2%2F5%2F2672413.html&ei=o_RWRunZCoH80gToiKHuBg&usg=AFrqEzeiWV9Iuw547VUbJbrJCGvC-PS7Zg&sig2=h_1c2mSijA6VeWhCHGQTDA#woop'; if (is_valid_url($url)) { echo 'Yeah'; } PHP:
nico's solution will work in "most" cases, but assuming you're not using this on every page, the best option is fsockopen. http://php.net/fsockopen It'll give you an error code if it can't open the page. Otherwise it can be a valid URL by syntax, but it could be like www.youSuckDontTalkToMe.com, and not a real domain. hope this helps