Trigger 500 Internal Server Error in PHP and display Apache error page

前端 未结 9 1062
一整个雨季
一整个雨季 2020-12-25 11:30

How can i trigger 500 Internal Server Error or 404 Page Not Found Apache errors in PHP?

For 500 Internal Server Error i have tried

9条回答
  •  一整个雨季
    2020-12-25 11:52

    I'm probably quite late, but this solution should work

    header("HTTP/1.0 500 Internal Server Error");
    include("/path-to-public-html/errors/500.php");
    die();
    

    This will trigger a 500 ISE response, and show the default 500 error page, then stop the script. Obviously you will need to to modify the location of the included file

提交回复
热议问题