Error in getting the status code of current page-PHP
Geting this is the snippet in php which I have managed
$server="localhost";
function sockAccess($page)
{
$errno="";
$errstr="";
$fp=0;
global $server;
$fp=fsockopen($server,80,$errno,$errstr,30);
if($fp===0)
{
die("Error $errstr ($errno)");
}
$out="GET /$page HTTP/1.1\r\n";
$out.="Host: $server\r\n";
$out.="Connection: Close\r\n\r\n";
fwrite($fp,$out);
$content=fgets($fp);
$code=trim(substr($content,9,4));
fclose($fp);
return intval($code);
}
echo '".'.$_SERVER["REQUEST_URI"].'"';
echo "code=", " ", sockAccess('".'.$_SERVER["REQUEST_URI"].'"'), "\n";
echo "code=", " ", sockAccess("./test.php"), "\n";
echo "code=", " ", sockAccess("brokenlink.php"), "\n";
The problem is it still shows code=404 for echo "code=", " ", sockAccess('".'.$_SERVER["REQUEST_URI"].'"'), "\n";
is there anything wrong woth this code.If yes please help me out.Thankx for the help in advance.
Total Views: 13 Today Views: 0














