Last active
October 11, 2019 02:26
-
-
Save erlangparasu/f1821f87ec9c2c4bb13d8de9651bc93a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Preparing response data. | |
| $response = json_encode([ | |
| 'success' => true, | |
| 'time' => date('Y-m-d H:i:s') | |
| ]); | |
| // Keep process running after | |
| // connection closed by the browser. | |
| ignore_user_abort(true); | |
| // Kirim header sebagai signal agar | |
| // browser menampilkan data dan browser langsung | |
| // menutup koneksi. | |
| header('Content-Type: application/json'); | |
| header('Connection: close'); | |
| header('Keep-Alive: timeout=0, max=0'); | |
| header('Content-Length: '.mb_strlen($response)); | |
| echo $response; | |
| ob_flush(); | |
| flush(); | |
| // Now this script is disconnected from browser | |
| // but proccess still active. | |
| // Let's run the code behind the scenes | |
| sleep(10); // eg. request REST API |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment