gpt4 book ai didi

linux - 在 PHP CLI 中设置 max_execution_time

转载 作者:IT老高 更新时间:2023-10-28 12:37:48 27 4
gpt4 key购买 nike

我知道通常使用 PHP CLI 是因为没有时间限制,主要是因为它不使用 Apache 线程/进程。

但是有什么方法可以为一些我不想拥有“无限时间”的自由而只想控制这些脚本的脚本显式设置 max_execution_time?

如果您认为在 superuser.com 上可能会更好地回答这个问题并且有权移动它,那就去做吧。 :)

编辑:我用谷歌搜索了一下,找到了正确的参数:

php -d max_execution_time=5 script.php

最佳答案

documentation表示在命令行模式下运行时,默认为 0(无限制)。它并不是说你不能覆盖它:

set_time_limit(10); // this way
ini_set('max_execution_time', 10); // or this way

编辑:我自己试了一下,效果符合预期。

F:\dev\www>c:php -f index.php
PHP Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3

Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3

关于linux - 在 PHP CLI 中设置 max_execution_time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5874950/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com