continue processing php after sending http response

后端 未结 12 859
旧时难觅i
旧时难觅i 2020-11-22 13:06

My script is called by server. From server I\'ll receive ID_OF_MESSAGE and TEXT_OF_MESSAGE.

In my script I\'ll handle incoming text and ge

12条回答
  •  醉酒成梦
    2020-11-22 13:25

    If you're using FastCGI processing or PHP-FPM, you can:

    session_write_close(); //close the session
    ignore_user_abort(true); //Prevent echo, print, and flush from killing the script
    fastcgi_finish_request(); //this returns 200 to the user, and processing continues
    
    // do desired processing ...
    $expensiveCalulation = 1+1;
    error_log($expensiveCalculation);
    

    Source: https://www.php.net/manual/en/function.fastcgi-finish-request.php

    PHP issue #68722: https://bugs.php.net/bug.php?id=68772

提交回复
热议问题