如果是404 Not Found代码的结果,我想在页面上显示一些附加文本。我想在其他地方重复使用页面的其余部分。
<div>
<?php
if(page_is_404_redirect)
{
<div>Oh no, I couldn't find what you were looking for.</div>
}
>?
...
</div>
我在$_SERVER variable page上找不到任何似乎表明错误代码结果的内容。如何查看错误代码状态?
答案 0 :(得分:1)
<?php
$previous = $_SERVER['HTTP_REFERER'];
$headers = @get_headers($previous);
if($headers[0] == 'HTTP/1.1 404 Not Found')
{
echo "Previous page was 404 error";
}
?>