I want to take the user’s input, respond to them, and then update some stuff in the database. But the response doesn’t need the stuff from the database, so I don’t want the user to have to wait for it. Is there a way to say “I’m all done. Go ahead and send this to the user.” but then keep executing more PHP code?
Share
Take a look at exec() in php http://php.net/manual/en/function.exec.php. Just before the end of processing of your php page, you can fire a command with exec() like running a php script cli: http://php.net/manual/en/features.commandline.php (basically runs in the background.). Be sure to note (for exec()):
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.