Re: Action on 'Require' Fatal Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 9, 2008 at 4:49 PM, Joe Harman <cjharman@xxxxxxxxx> wrote:
> Hello,
> is there a way to call a function or do a header("Location: page.php") when
> a fatal error is detected from using a the require statement
>
> Thanks
> Joe Harman
>

You can set up a custom error handler.  This will intercept every
single error and pass it to your function allowing you to do whatever
you want.  One thing to keep in mind though is that if there is a
fatal error you're kinda in a hard spot since memory limits could have
been hit, etc.  I use this technique sometimes to include an error
page (not header redirect to it).  It won't help you on a parse error
though.  Luckily I use the PDT editor which has real-time parse error
checking so I don't ever have that issue anyways.

Another solution that I've seen Rasmus say is that you can start your
script off with an error header and content and then if your script
logic/whatever completes okay, set the header back to 200 and replace
the error content with the real generated stuff.

Good luck!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux