How can I get php to return 500 upon encountering a fatal exception?

后端 未结 10 1507
孤独总比滥情好
孤独总比滥情好 2020-12-24 10:37

PHP fatal errors come back as status code 200 to the HTTP client. How can I make it return a status code 500 (Internal server error)?

10条回答
  •  青春惊慌失措
    2020-12-24 10:55

    Standard PHP configuration does return 500 when error occurs! Just make sure that your display_errors = off. You can simulate it with:

    ini_set('display_errors', 0); 
    noFunction();
    

    On production display_errors directive is off by default.

提交回复
热议问题