How to make PHP set HTTP status code to 500 automatically in case of any error condition? (including those that cannot be handled by user)

穿精又带淫゛_ 提交于 2019-11-29 16:53:57

I assume you are using a custom error handler to emit the 500.

I don't know XDebug that well, but according to this article, it registers its own error handler, probably overriding yours in the process:

Please note that the extended error display of xdebug does not work if you define a custom error handler using register_error_handler(). This is because xdebug internally uses the same mechanism. Should your scripts use a custom error handler, you can still use the function xdebug_get_function_stack() to output the stack trace in your custom error handler.

However, for production use, you are not going to activate XDebug anyway, are you?

As for why a 200 is output when you activate display_errors(), that I don't understand. Can you post your custom error handler function to look at?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!