久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

限制函數或命令 PHP 的執行時間

Limit execution time of an function or command PHP(限制函數或命令 PHP 的執行時間)
本文介紹了限制函數或命令 PHP 的執行時間的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

是否可以僅對命令或僅對函數設置時間限制,例如:

Hi is there a possibility to set time limit only to a command or only to a function eg:

function doSomething()
{
    //..code here..

    function1();

    //.. some code here..

}

我只想為function1設置時間限制.

I want to set time limit only to function1.

有退出 set_time_limit 但我認為這設置了整個腳本的時間限制.有人有什么想法嗎?

There exits set_time_limit but I think this sets the time limit to whole script. Anybody any Idea?

推薦答案

set_time_limit() 確實在全局運行,但可以在本地重置.

set_time_limit() does run globally, but it can be reset locally.

設置允許腳本運行的秒數.如果達到了,該腳本返回一個致命錯誤.默認限制為 30 秒,或者,如果存在,php.ini 中定義的 max_execution_time 值.

Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

調用時,set_time_limit() 從零重新啟動超時計數器.在換句話說,如果超時是默認的 30 秒,和 25 秒進入腳本執行調用如 set_time_limit(20) 時,腳本將在超時前總共運行 45 秒.

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

我沒有測試過,但你可以在本地設置,離開時重置

I've not tested it, but you may be able to set it locally, resetting when you leave the

<?php
set_time_limit(0);  // global setting

function doStuff()
{
    set_time_limit(10);   // limit this function
    //  stuff
    set_time_limit(10);   // give ourselves another 10 seconds if we want
    //  stuff
    set_time_limit(0);    // the rest of the file can run forever
}

// ....
sleep(900);
// ....
doStuff();  // only has 10 secs to run
// ....
sleep(900);
// ....

set_time_limit()... 在確定腳本運行的最長時間時,不包括在腳本執行之外發生的活動上花費的任何時間,例如使用 system() 的系統調用、流操作、數據庫查詢等.在測量時間是真實的 Windows 上,情況并非如此.

這篇關于限制函數或命令 PHP 的執行時間的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 妹子干综合 | 精彩视频一区二区三区 | 黑人久久 | 91一区二区三区 | 日本三级在线 | www.日韩高清| 欧美一级欧美三级在线观看 | 亚洲成人av在线 | 日韩欧美国产一区二区三区 | 成人激情视频免费观看 | 亚洲一区二区三区在线视频 | 在线伊人 | 久久99精品国产99久久6男男 | 精品久草 | 一区二区在线不卡 | 免费国产黄网站在线观看视频 | 久综合 | 中文字幕不卡在线观看 | www.com久久久| 国产丝袜人妖cd露出 | av在线免费播放 | 亚洲欧美日韩久久久 | 精久久| 日韩电影中文字幕 | 欧美无乱码久久久免费午夜一区 | 欧美在线观看免费观看视频 | 国产精品成人一区二区三区夜夜夜 | 97精品超碰一区二区三区 | 亚洲精品久 | 国产精品久久久久久久久久三级 | 欧美一区二区免费在线 | 福利视频一区二区三区 | 激情的网站 | 成人久久久 | 免费看的黄网站 | 国产婷婷色综合av蜜臀av | 黄片毛片| 黄色国产在线视频 | 亚洲精品乱码久久久久久按摩观 | 午夜在线视频 | 国产毛片毛片 |