Every one of my pages starts with a common php file. What I would like to do is within the common file, call a function/class which does "stuff", but in the background. So I would like to "initiate" the call, but then just move on with my script so the user doesn't wait for the function/class to finish its execution.
There's no output from this function/class it just performs its activity with session/environment variables, etc.
Thanks.
How can I run a PHP function asynchronously?
You will run up against the PHP 30 second timeout which will kill your script. PHP has no explicit thread support. You could do it by getting tricky, depending on what exactly you need to do.
You might consider callings something external and pass it all the info you want processed (via a pipe or file). You can program the task in any language the server supports.
Here is a 'threads' search on the php.net website. Might be enough...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment