note 120200 deleted from function.register-shutdown-function by cmb
| From: | cmb@php.net | Date: | Sun, 24 Nov 2019 08:58:55 +0000 |
| Subject: | note 120200 deleted from function.register-shutdown-function by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213227@lists.php.net to get a copy of this message | ||
Note Submitter: no at pls dot com
----
I used register_shutdown_function to send an error code in http headers if max execution time was
exceeded, executing the registered function IS the stated behavior but it used to not do that when i
first tried it (i know, too lazy to read).
I ended writing this for the behavior i wanted:
register_shutdown_function(
function(){
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
$limit = ini_get('max_execution_time');
if($time >= 0.9 * $limit){
http_response_code(500);
}
}
);