PHP未找到自定义404 [英] Customized 404 not found with PHP

查看:125
本文介绍了PHP未找到自定义404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码显示PHP找不到的Cutom 404:

I am using the following code to display a cutom 404 not found with PHP:

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include('404.php');
exit();

但是,将显示默认浏览器的404页面.在包含PHP文件的同时产生404的正确代码是什么?

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

谢谢

乔尔

推荐答案

但是,将显示默认浏览器的404页面.在包含PHP文件的同时产生404的正确代码是什么?

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

当输出的页面大小小于512字节时,某些浏览器(即IE和Chrome)显示它们自己的404页面.

Some browsers (namely IE and Chrome) show their own 404 page when the size of the page that was output is less than 512 bytes.

将输出内容超出此范围.我喜欢使用

Pad your output to go beyond that. I like to use some nice ASCII art.

这篇关于PHP未找到自定义404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆