久久久久久久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)
主站蜘蛛池模板: 一级片免费在线观看 | 日日摸天天添天天添破 | 中文字幕第二区 | 99re视频在线免费观看 | 久久视频免费观看 | 日韩在线不卡视频 | 日韩欧美在线视频一区 | 在线国产中文字幕 | 亚洲免费在线视频 | 日韩免费1区二区电影 | 亚洲1区 | 亚洲成人二区 | 天天操天天干天天曰 | 亚洲九九精品 | 国产精品夜夜春夜夜爽久久电影 | 亚洲精品一区二区三区中文字幕 | 成年网站在线观看 | 亚洲www啪成人一区二区麻豆 | 欧美成人二区 | 日韩一区二区三区视频 | 久久99精品久久久 | 精品一区二区三区四区外站 | 91.色| 国内精品久久影院 | 久久久91精品国产一区二区三区 | 国产在线网站 | 午夜精品久久 | 色香婷婷 | 亚洲视频一区在线观看 | 中文字幕亚洲视频 | 天天搞天天操 | 亚洲精品视频网站在线观看 | 欧美极品一区二区 | 久久国产一区 | 免费成人高清在线视频 | 日韩在线观看 | 国产一区二区三区 | 日韩在线免费 | 成人精品久久日伦片大全免费 | 久久精品免费一区二区 | 日韩成人av在线 |