Take the 2-minute tour ×
function truExceptionHandler($no, $str, $file, $line) {
    if ($str != "Only variables should be assigned by reference") {
        echo '<br/><pre>';
        echo "<b>[ERROR] ".$str." in ".$file." on line ".$line."</b><br/>";


My above function isn't catching the error Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\Program Files (x86)\EasyPHP-\www\site.com\system\core\Common.php on line 328

What do I need to change to be sure it's caught?

share|improve this question

3 Answers 3

A fatal error is fatal. You can't catch it, PHP is now DOA. In particular, that error is a stack overflow. It makes little sense in the context of a stack overflow to expect PHP to create a new stack frame to call your error handler.

share|improve this answer
Then how can I determine the cause of this error? How can I figure out what functions are looping? –  Webnet May 4 '11 at 2:34
@Webnet: Code inspection, or perhaps something like xdebug may be useful too. On an unrelated note, this is one of my pet peeves in PHP. –  Matthew Scharley May 4 '11 at 2:35

Normally you cannot catch a fatal error. That's why they are called fatal errors. But, if you really want to, there's a dirty little hack that you can use. Use register_shutdown_function. Shutdown functions are still called after a FATAL_ERROR has occured. E.g:

function onShutdown()
    $error = error_get_last();
    if (null !== $error && E_ERROR === $error['type']) {
        // A FATAL_ERROR occured


Let me repeat to drive the point home: This is a dirty hack (but it works)!

share|improve this answer

Sounds like a recursion error. It basically means you have 100 function calls on the stack i.e. if function a1 calls function a2 which calls function a3 ....... calls function a100.

share|improve this answer

Your Answer


