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)

前端 未结 1 378
借酒劲吻你
借酒劲吻你 2020-12-21 23:29

I am running Apache 2.2.15 with PHP 5.3.2, \'display_errors\' disabled, \'display_startup_errors\' disabled, \'log_errors\' enabled.

At my setup (so I consider it a

相关标签:
1条回答
  • 2020-12-22 00:02

    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?

    0 讨论(0)
提交回复
热议问题