M
M
Michael2015-10-01 10:58:58
PHP
Michael, 2015-10-01 10:58:58

Can a PHP script be interrupted when the browser is closed?

Good afternoon!
The site runs a function once a day, when entering the page, sometimes it can work for a long time 10-30 seconds, at which time the user can close the page or browser
In the near future, this script will be hung on cron, but at the moment the script sometimes does not work correctly, can the PHP script be interrupted when the browser is closed?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Optimus, 2015-10-01
@xmentor

Yes, when the connection with the client is interrupted, the work of a long script is interrupted, so that this does not happen, put it at the beginning of the script:
In this case, the script will always work to the end even if the browser was closed.

D
Dmitry Kovalsky, 2015-10-01
@dmitryKovalskiy

Not

N
Nurlan, 2015-10-01
@daager

If you have php-fpm then use fastcgi-finish-request in your script . The function immediately causes the browser to display the response, but the script continues to run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question