Hi I'm looking for a very simple code snippet.

I have a program written, and if there is a fatal error I want it to stop and output some text.

Something like:

try
{

//program here

}catch
{

echo "We're sorry contact the site administer blah blah blah";

}

So far I have only been able to find error handling where you script an exception to be thrown in a specific instance. I don't want to do this. I could never be sure if I found ever possible problem. If there is a general error I want the program to stop and output a generic message.

Can you please post the code for this?

    You can use [man]set_error_handler/man to call your own error-handling function -- which could be used to [man]throw[/man] and exception if you want. However, note the manual info on which types of errors can/cannot be handled by such a custom handler.

      ok What I think I need to do is set this in apache. So if there is a parse error or fatal error have it say my message.

        cysten;10955037 wrote:

        ok What I think I need to do is set this in apache.

        Are you implying that you don't know how to do this? If so, see this manual page: [man]configuration.changes[/man]. Basically, if PHP was loaded as an Apache module (rather than a CGI binary; do a [man]phpinfo/man and look at the first table at the top to determine this), you can use the "php_*" Apache directives in a .htaccess file in the root of your site.

          • [deleted]

          look at the first table at the top to determine this), you can use the "php_*" Apache directives in a .htaccess file in the root of your site. I have a program written, and if there is a fatal error I want it to stop and output some text.So far I have only been able to find error handling where you script an exception to be thrown in a specific instance. I don't want to do this. I could never be sure if I found ever possible problem. If there is a general error I want the program to stop and output a generic message.

            Write a Reply...