code.youlikeshare.com
Enter Website URL for checking:
PHP Code

	//check if website is up or down
	$website_down = is_website_down($url, $http_code);
	if (!$website_down){
		echo "Website is up!";
	}
	else{
		echo "Website is down!";
	}
	
	//function to check if the website is up or down
	function is_website_down($url, &$http_code)
	{
		//initialize curl
		$handle = curl_init($url);
		curl_setopt($handle,CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($handle,CURLOPT_HEADER,true);
		curl_setopt($handle,CURLOPT_NOBODY,true);
		curl_setopt($handle,CURLOPT_RETURNTRANSFER,true);

		//invoke curl to check the page return
		$response = curl_exec($handle);
		
		//optional: you may get the http status code for custom implementation
		$http_code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
		if ($http_code == 404){
			//TODO
		}
		
		//close the curl handle
		curl_close($handle);

		//return the status to caller
		if ($response)
			return false;
		else
			return true;
	}

Below are HTTP Status Code Definitions (RFC 2616) from w3.org
HTTP Status Code HTTP Status Code Description
1xx: Informational
100Continue
101Switching Protocols
2xx: Successful
200OK
201Created
202Accepted
203Non-Authoritative Information
204No Content
205Reset Content
206Partial Content
3xx: Redirection
300Multiple Choices
301Moved Permanently
302Found
303See Other
304Not Modified
305Use Proxy
306(Unused)
307Temporary Redirect
4xx: Client Error
400Bad Request
401Unauthorized
402Payment Required
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable
407Proxy Authentication Required
408Request Timeout
409Conflict
410Gone
411Length Required
412Precondition Failed
413Request Entity Too Large
414Request-URI Too Long
415Unsupported Media Type
416Requested Range Not Satisfiable
417Expectation Failed
5xx: Server Error
500Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported