Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:10:14+00:00 2026-05-26T10:10:14+00:00

Whenever there is a call to an undefined function, no errors are logged. Instead

  • 0

Whenever there is a call to an undefined function, no errors are logged. Instead the script just stops executing. To make things worse, if I run php -l filename.php, It shows that there are no syntax errors. I am using a custom error handler function, but even the first line is never reached.

How can I get it to run my error handler when there is a call to an undefined function?

I am using PHP 5.3.2-1. Here is the code that is setting the error handler:

error_reporting(-1);
$old_error_handler = set_error_handler( "userErrorHandler" );
set_exception_handler('exception_handler');

Neither the error handler nor the exception handler are being reached, although they do work for other errors.

The reason I want this is I end up having to place debug statements in my code to see how far it gets before it stops executing which is a slow process compared to an error message that would tell me the file and line number where the error is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:10:15+00:00Added an answer on May 26, 2026 at 10:10 am

    Fatal errors can not be caught by a user error handler.

    See http://php.net/manual/en/function.set-error-handler.php

    Specifically the part:

    The following error types cannot be handled with a user defined
    function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
    E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the
    file where set_error_handler() is called.

    And as per the comments on the PHP manual page, one work around is to test for errors in the shutdown function:

    <?php
        error_reporting(E_ALL);
        ini_set('display_errors', 0);
    
        function shutdown(){
            $isError = false;
            if ($error = error_get_last()){
                switch($error['type']){
                    case E_ERROR:
                    case E_CORE_ERROR:
                    case E_COMPILE_ERROR:
                    case E_USER_ERROR:
                        $isError = true;
                        break;
                }
            }
    
            if ($isError){
                echo "Script execution halted ({$error['message']})";
            } else {
                echo "Script completed";
            }
        }
    
        register_shutdown_function('shutdown');
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to make sure my thread reacts on whenever there is network
On my 8-bit Freescale HCS08 micro, whenever I call a library function that returns
I intend to call a function whenever m_logger<<hello<<world is called. m_logger is of type
I need to call function whenever class is created using new. Currently I need
Whenever I called my function, memory usage is increased around +10M per call, so
My whole page is loading again whenever I make a ajax call to load
There is a function that triggers a callback when finished; I call this function
I have configured a SMTP appender to send an email whenever there's an error.
I don't want to change the java code whenever there is addition of tag
I have a Flash app with a PHP backend. Whenever there is a PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.