- register_tick_function: documentation ( source)
<?php
register_tick_function(function () {
echo "Tick", PHP_EOL;
throw new \Exception("Software interrupt");
});
declare(ticks=1e2) {
try {
$loopIndex = 0;
while ($loopIndex < 1e3) {
$loopIndex++;
echo "Index {$loopIndex}", PHP_EOL;
}
} catch (\Exception $e) {
echo "Received termination signal";
}
}