how to trigger a 503 on error
Moderator: General Moderators
-
mybikeisgreen
- Forum Newbie
- Posts: 22
- Joined: Thu Oct 01, 2009 6:22 pm
how to trigger a 503 on error
I'm working on a php page that accepts automated requests. The automated requests look for a response code from the page. When it see 200 OK it infers the light is green, and everything worked as it should have. So I'd like for it to give a 503 response code if there is any kind of error, such as an include file missing or a mysql error. Is there a setting in PHP that I can set to make it do that? I only want to do it for this one page, not the whole site/server.
Re: how to trigger a 503 on error
Take a look at the manual page for header().
-
mybikeisgreen
- Forum Newbie
- Posts: 22
- Joined: Thu Oct 01, 2009 6:22 pm
Re: how to trigger a 503 on error
Thanks but that page tells you how to manually create a 503 response header. I want it to happen automatically and only in case of an error.
-
mybikeisgreen
- Forum Newbie
- Posts: 22
- Joined: Thu Oct 01, 2009 6:22 pm
Re: how to trigger a 503 on error
Still looking for an answer here. I was hoping that there was something I could do with the error_reporting() function to make this work.
But it's starting to look like I'll need to use try{} catch()
But it's starting to look like I'll need to use try{} catch()
Re: how to trigger a 503 on error
You can set an error and an exception handler (guess what the function names are) to automatically send that header() if there's a problem.
As for a setting to PHP to do it for you, I don't know of any such thing.
As for a setting to PHP to do it for you, I don't know of any such thing.
-
mybikeisgreen
- Forum Newbie
- Posts: 22
- Joined: Thu Oct 01, 2009 6:22 pm
Re: how to trigger a 503 on error
This answer was not very helpful. Why not elaborate or provide code examples?
Thanks.
Re: how to trigger a 503 on error
trigger_error() and set_error_handler().