是否有可能启动一个代码块(也许只是调用一个函数),如果它在一定时间内没有执行,则跳过它。我可以设置代码块的时间限制吗?
//give this function 10 seconds to execute
$value = mega_function();// could take anything from 1-1000 seconds
//if 10 seconds have passed and the value is still not set, abort it and set $value = false;
兆功能是一个程序,试图解释各种文本块,所以为了获得更快的结果,我们只是想跳过那些需要更多时间的现在,我想我需要优化代码,并可能使用另一种语言,而不是php,但是,有,我的工具 – Moak 2011-05-11 07:15:35
如果它真的调用一个外部程序,你可以跟踪时间并杀死'mega_function()'里面的外部进程。 – tobyodavies 2011-05-11 07:17:47
你也可以从PHP启动一个进程,检索PID,控制。然后检查一段时间外部脚本的PID状态。 – 2011-05-11 07:33:24