Detecting a timeout for a block of code in PHP

后端 未结 9 1660
[愿得一人]
[愿得一人] 2021-02-02 16:44

Is there a way you can abort a block of code if it\'s taking too long in PHP? Perhaps something like:

//Set the max time to 2 seconds
$time = new TimeOut(2);
$ti         


        
9条回答
  •  你的背包
    2021-02-02 17:02

    I made a script in php using pcntl_fork and lockfile to control the execution of external calls doing the kill after the timeout.


    #!/usr/bin/env php
    

    Test Script run.php

提交回复
热议问题