Are you looking for some thing like this ? /* - Usages for check_url function. If(check_url("http://www.weberdev.com/get_example-4335.html")) { Echo"URL Exists"; }Else{ Echo"URL doesnot exist"; } */ function check_url($url) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_HEADER, 1); // get the header curl_setopt($c, CURLOPT_NOBODY, 1); // and *only* get the header curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // get the response as a string from curl_exec(), rather than echoing it curl_setopt($c, CURLOPT_FRESH_CONNECT, 1); // don't use a cached version of the url if (!curl_exec($c)) { return false; } $httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE); return ($httpcode < 400); } PHP:
Hi krinad'suza, Do you mean validation of the URL's syntax? As in the placements of the TLD components, such as checking whether a given URL is in valid URL format, or are you looking to validate that the URL itself exists and is accessible? If the former, then you need to read up on regular expressions - such as PHP regex functions - if the latter, then you need to read up on PHP's cURL library - as it's quicker and more powerful than the built-in data stream functions and it allows you to configure the HTTP headers meaning your request isn't going to be refused by the target URL. I have experience with connections, streams and sockets being used in this way as I had to research considerably for an older project's webcrawler. I hope this helps, Lee.