Php - Find an url exists in php or not, Search fo url in a file
Find an url exists in php or not
Check wheather a url exists in a files or not.function urlOK($url) { $url_data = parse_url ($url); if (!$url_data) return FALSE; $errno=""; $errstr=""; $fp=0; $fp=fsockopen($url_data['host'],80,$errno,$errstr,30); if($fp===0) return FALSE; $path =''; if (isset( $url_data['path'])) $path .= $url_data['path']; if (isset( $url_data['query'])) $path .= '?' .$url_data['query']; $out="GET /$path HTTP/1.1rn"; $out.="Host: {$url_data['host']}rn"; $out.="Connection: Closernrn"; fwrite($fp,$out); $content=fgets($fp); $code=trim(substr($content,9,4)); fclose($fp); return ($code[0] == 2 || $code[0] == 3) ? TRUE : FALSE; } if (urlOK($url)) echo " is a working URL"; else echo " is a bad URL"; ?>
The topic on Php - Find an url exists in php or not is posted by - Math
Hope you have enjoyed, Php - Find an url exists in php or notThanks for your time