Headers will not work (they are headers, so they come first)
I do not know how to close the http connection without ending the script, although I assume there is some obscure way to do this.
Telling us what you want to do after the request is completed, we can give the best deals.
But actually, I would think of one of the following:
1) Run a simple script command line (using exec ()) that looks like this:
#!/bin/sh php myscript.php <arg1> <arg2> .. <argN> &
Then remove this from your http-bound script, like:
<?PHP exec('/path/to/my/script.sh'); ?>
Or:
2) Write another program (perhaps a constantly running daemon or just some kind of script that happens so often), and find out how your request code can pass instructions to it. You may have a database table in which the queue runs, or try to make it work with some kind of flat file. You can also use your web-based script to invoke some command line command, due to which your external script request should do some work.
At the end of the day, you do not want your script to continue executing after an HTTP request. Assuming you are using mod_php, this means that you will bind the apache process until the script completes.
timdev
source share