开发者

Triggering HTTP Errors: 4xx 5xx via HTML/PHP

开发者 https://www.devze.com 2023-04-05 01:34 出处:网络
Is there any method in HTML or PHP to force-trigger specific HTTP 1.1 errors, such as 404, 403, 400, 500, etc.?I n开发者_如何学Goeed a method to test an .htaccess setup for error docs on a site on one

Is there any method in HTML or PHP to force-trigger specific HTTP 1.1 errors, such as 404, 403, 400, 500, etc.? I n开发者_如何学Goeed a method to test an .htaccess setup for error docs on a site on one of my servers.


Check out the header function, example:

header("HTTP/1.0 404 Not Found", TRUE, 404);

Examples: here!


Simply use the header function, as you would for any other HTTP header.

header("HTTP/1.0 404 Not Found");
die;

You can basically write whatever you want after the status code, it should still work the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号