I am trying out the folowing piece of code:
<?php
$site1 = 'http://www.teraasdsfssgggdadafasfra.com.br';
$handle = curl_init($site1);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Gets the HTML or whatever is linked in the $url. */
$response = curl_exec($handle);
/* Gets the HTTP code */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
echo $httpCode;
curl_close($handle);
?>
something like this in response to Abra http://www.google.com exists but jkshakl... will give you the 404 error you expect
<?php
$site1 = "http://www.google.com/jkdshaklfjhdasf";
$handle = curl_init($site1);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Gets the HTML or whatever is linked in the $url. */
if($response = curl_exec($handle)){
/* Gets the HTTP code */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
echo $httpCode;
curl_close($handle);
}
else echo "server does not exist";
?>