PHP source code is only displayed when apache is not properly configured to handle php files. That is, when the correct handler is not defined.
In case of errors, what is shown can be set to php.ini, basically the display_errors variable. This should be disabled and log_errors enabled in the production environment.
If php does die, apache will return the appropriate HTTP status code (usually 500) with the page specified by the ErrorDocument directive. If he is not dead, but stuck in a loop, you cannot do as far as I know.
You can specify a different page for different error codes.
source share