得到这是我管理的php中的片段
$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 '"php self='. $_SERVER['PHP_SELF'].'"';
if(($_SERVER['PHP_SELF']) == ($_SERVER['REQUEST_URI'])}
{
echo "code=", " ", sockAccess('".'.$_SERVER["REQUEST_URI"].'"'), "\n";
}
else
{
echo "code=", " ", sockAccess('".'.$_SERVER["REQUEST_URI"].'"'), "\n";
}
echo "code=", " ", sockAccess("./test.php"), "\n";
echo "code=", " ", sockAccess("brokenlink.php"), "\n";
问题是它仍然显示code=404
回"code=", " ", sockAccess('".'.$_SERVER["REQUEST_URI"].'"'), "\n";
显所以我认为的解决方案可能是它没有读取已经运行的文件。所以我通过使用 if else 修改了 bove 代码。但现在文件 dosent 运行。这是错误的。提前谢谢。