ConFoo Montreal 2026: Call for Papers

Voting

: four minus three?
(Example: nine)

The Note You're Voting On

Daan
4 years ago
If you would like to calculatue the wall time of your script (includes all external DB/HTTP calls etc.) in Unix (in Windows this is already default behavior), you could use the following function:

<?php

$timeoutInSeconds
= 3;

// This will make sure this is always called async
pcntl_async_signals(1);

// Second parameter is any callable (https://www.php.net/manual/en/language.types.callable.php)
pcntl_signal(SIGALRM, function() {
exit(
'Stop it!');
});
pcntl_alarm($timeoutInSeconds);

?>

<< Back to user notes page

To Top