Check if a URL exists and return code not 404(not found) with cURL PHP
By admin • Mar 24th, 2010 • Category: Web ProgrammingHere is a simple function that will do just that, determine if a website exists using PHP and cURL. It’s check http code, if http code is 404 (Not Found) it will return false. function urlExists($url=NULL) { if($url == NULL) return false; $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data [...]


