Hello,
I'm try to find code that will return the status code of some url. for example: 200 (if the page is OK), 404 (Not Found), 500 (Internal Server Error) and ect -
http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html
I found the following code but I don't know how to keep the status code (only the number) in variable...
?
$host = "www.cnn.com";
$uri = '/';
$fp = fsockopen("$host", 80, $errno, $errstr, 30);
if(!$fp)
{
echo "$errstr ($errno)<br />\n";
return;
}
else
{
fwrite($fp,"HEAD $uri HTTP/1.0\r\n");
fwrite($fp,"Host: $host\r\n");
fwrite($fp,"Connection: Close\r\n");
fwrite($fp,"\r\n");
while (!feof($fp)) {
$content .= fgets($fp, 128);
}
fclose($fp);
}
echo '<p>Results for <a href="\"http://$host$uri\">http://$host$uri</a></p>';
echo '<textarea cols="55" rows="9" wrap="off">';
echo $content;
echo '</textarea><br /><hr /><br />';