Assuming that you not only want to send the 500
header (which is very simple), but to actually trigger a 500 error on the Apache system, there seems to be no trivial solution.
According to this question , this is the default PHP behavior with PHP 5.2.4 if:
- a fatal error occurs and
- document body is empty (Gordon found an entry in the change log here ).
I am not sure how reliable this behavior is in the long run (i.e. when PHP 6 appears, etc.). This is not a very advertising feature.
Other than that, I don't know how to provoke 500 after running the script. I asked something similar for 404s once. The answer provided there (redirecting to a predefined URL and sending a 500 header) may be the best you can get - although this, of course, will not be logged.
source share