anonymous-one
anonymous-one

Reputation: 15112

Instruct mod_php to issue a html status code when script error occurs - Possible?

Imagine for a second you have the following php based page served via apache + mod_php :

<?
blahblah!!!_!_!(___);
?>

This is obviously invalid php, and the script would fail.

Is there any way to signal to mod_php / apache / php.ini (?) to issue a 5xx based status code + document body when this happens?

Ideally one that I could edit / create on my own...

Thanks!

Upvotes: 0

Views: 115

Answers (1)

Mike Brant
Mike Brant

Reputation: 71384

Your best bet is to look at defining custom error handlers and a shutdown function in PHP to do this for you.

You would just capture the error, and you could then send custom 5XX error header and whatever additional content (i.e. custom error page) you desire.

The following links in the PHP manual should get you what you need.

set_error_handler manual

register_shutdown_function manual

header manual

Upvotes: 1

Related Questions