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

  • Home
  • SEARCH
  • 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 3693112
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:20:22+00:00 2026-05-19T04:20:22+00:00

I’m currently using register_shutdown_function() for multiple purposes. One use is for handling fatal errors,

  • 0

I’m currently using register_shutdown_function() for multiple purposes. One use is for handling fatal errors, while the other is for logging resources used during execution like time, memoryusage etc.

Currently I register two different shutdown functions, but on one test only the first ran while the other seemed to fail. Now this could ofcourse be triggered by some error within the function itself so I have rewritten it, but is it possible an error was caused by using several register_shutdown_function calls? So what is considered best practice here, to registert two different functions or just make the call to one function that handles the different tasks?

Is it also safe (and possible) to make the function load a class for errorhandling if a fatal error occurs or should I keep the functionality within the function itself?

The final question I got is if there’s a better way to handle fatal errors than using shutdown functions? I tried using set_error_handler, but it does not cover all errortypes so some errors will not trigger this.

Hope these questions are well formulated and clear. My goal is to keep the code as solid as possible and I could not find any decent answers to the questions I had.

*Edit: Found the answer to my first question, registering several functions should be no problem so the error had to be within the function itself. Leaving the question up to get answers to whether there’s a better ways to handle fatal errors.

  • 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-19T04:20:23+00:00Added an answer on May 19, 2026 at 4:20 am

    IIRC, if you have multiple shutdown functions registered, they will be executed in the order in which they were registered; and you should never have an exit statement in any, otherwise subsequent shutdown functions will not be run. That means you need to take great care if you have multiple functions rather than a single shutdown function.

    However, if you’re passing different arguments to the different functions, you should ensure that you have default values for them all in case the functions are called (perhaps triggered by an error) before all the appropriate variables are set.

    Personally, I register multiple functions, for similar purposes to yourself; but I’m very careful about the logic within them, and the order of registration.

    It’s also not a good idea to use includes or similar in shutdown functions (especially where one is an exception handler), in case the include itself triggers an exception

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.