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

前端 未结 9 1090
一整个雨季
一整个雨季 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:57

    Apparently there is a function called http_response_code that will let you set the response code appropriately. If that doesn't work (there's a note in the documentation about it possibly being only in SVN) then the header function can take an optional response code argument:

    header("HTTP/1.0 ...", true, 404);
    

    This should signal Apache correctly.

提交回复
热议问题