PHP set allowed function execution time, return default if execution time is surpassed

时间:2018-06-04 17:15:32

标签: php

Is there a way for me to allot say - two seconds for a function to execute, and if it surpasses that amount of time, return a default value?

function foo() {

   // call out to URL and get info...

   // if this takes longer than 2 seconds, return $a
   // else, return $b


}

0 个答案:

没有答案