duannuo7878 2011-10-07 04:46
浏览 31
已采纳

如何在PHP中设置特定执行的超时?

What I am trying to do is, I am running queries against Twitter and if the deliver of the result delays more than a specific time, than I want to say to user that "Please try again later, timeout." I am not asking the Twitter part, I told my story because of the initial explanation but I like to learn how to accomplish it with mostly PHP native codes.

What's in my mind would be something below:

startTimeout(callback(),3000);//Probably this function needs to start a new thread or another concurrent execution scope
//... initiating some twitter queries here

function callback()
{
   echo "Time out, sorry";
}
  • 写回答

2条回答 默认 最新

  • dongwei2610 2011-10-07 13:42
    关注

    set_time_limit() should do the trick. This defines the number of seconds that the script can run.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo