Actually, the script will work as long as not executed completely or until it reaches the max_execution_time
parameter (in php.ini
), usually it is 30 seconds, but with access to php.ini you can set this time up to infinity. If running PHP from the console - this option has no effect, but that's not the case. And what do you mean by "end of page" - nothing more than resetting the buffer
, but do not forget that a web server can have its own buffer, which may also have to configure what the server does not "hang" waiting.
That is, this algorithm, you start a script, as a result of the AJAX request is sent to the output data You need (using print/echo), when the last batch of data sent - make flush()
, and... the script continues to work on.
Also, the buffer is automatically cleared (sent to the browser and/or intermediate server) at the end of the script, that's why "end of script" do You associate with the "end page".