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 6111721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:48+00:00 2026-05-23T14:39:48+00:00

I am trying to call a function after the page has been sent to

  • 0

I am trying to call a function after the page has been sent to the browser, but I haven’t found a way to do so.

I have tried both register_shutdown_function and __destruct but it does not work.

This is the structure I have:

register_shutdown_function('MyClass::Save');
MyClass::Initialize();
CreateAllOutput();

MyClass::Save has a sleep(20) inside.

The shutdown function gets called after the CreateAllOutput(), but the truth is that the loading bar on the browser only finishes after the Save function has been executed, waiting 20 seconds… I tried the same using a non static class and __destruct having a sleep(20) inside, and the same happens.

Is there a way of getting the function to only be executed after the output has all been sent to the browser?

Thank you in advance.

  • 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-23T14:39:48+00:00Added an answer on May 23, 2026 at 2:39 pm

    Generally: no. There is no possibility except to flush all output and then call it, but the loading bar in the browser won’t finish either.

    The only thing I can think of is putting an iFrame into the page to call a PHP file with the save function. Or you could make an Ajax call.

    A third possibility would be to call exec() (Documentation). After making a php file executeable you can run it with that method. As mentioned in the documentation:

    If a program is started with this
    function, in order for it to continue
    running in the background, the output
    of the program must be redirected to a
    file or another output stream. Failing
    to do so will cause PHP to hang until
    the execution of the program ends.

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

Sidebar

Related Questions

I'm trying to call a function after I load some XML into Actionscript, and
I'm trying to call a function inside another function in python, but can't find
I am trying to call my function named isUrgencyTypeValid from my javascript code but
I'm trying to call an accessor function in a copy constructor but it's not
I am trying to call a javascript in a html page using the function
I am trying to call the __doPostback javascript function in a asp.net page from
I've been implementing a certain plugin (dtabs) on my page in Wordpress but after
I'm trying to call a function in a Python script from my main C++
I'm trying to call a function from a form within the same .php file,
I'm trying to call a function that contains jQuery code. I want this function

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.