[英]What is the maximum allowed value of max_execution_time in php.ini
I tried increasing the value of max_execution_time in php using我尝试在 php 中使用增加 max_execution_time 的值
ini_set('max_execution_time', 108000);
which equals to 30 hours.相当于 30 小时。 I was just playing with this value to crawl websites with large amount of data in it.
我只是在玩这个值来抓取包含大量数据的网站。 But, I go this fatal error that said the maximum execution time cannot exceed 30 seconds.
但是,我遇到了这个致命错误,说最大执行时间不能超过 30 秒。 When I changed 108000 value to 300, my script executed for 5 minutes.
当我将 108000 值更改为 300 时,我的脚本执行了 5 分钟。 I wonder what is the maximum allowed value for this thing in php?
我想知道 php 中这个东西的最大允许值是多少?
Correct answer in reference to Mjh's comment.参考 Mjh 的评论的正确答案。
Signature for parsing integer ini values:用于解析整数 ini 值的签名:
ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
Therefore the maximum value that can be entered into that field is: 2147483647因此,可以在该字段中输入的最大值是:2147483647
Old answer.旧答案。
The only clue I could find was here: https://github.com/php/php-src/blob/master/main/php_ini.h我能找到的唯一线索在这里: https : //github.com/php/php-src/blob/master/main/php_ini.h
#define php_ini_long zend_ini_long
Which eventually leads back to: https://github.com/php/php-src/blob/master/Zend/zend_long.h最终回到: https : //github.com/php/php-src/blob/master/Zend/zend_long.h
typedef int64_t zend_long;
That is a 64 bit integer, or:那是一个 64 位整数,或者:
−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
EDIT: Correction.编辑:更正。
// PHP x64
typedef int64_t zend_long;
// PHP x86
typedef int32_t zend_long;
So the max value is PHP_INT_MAX
.所以最大值是
PHP_INT_MAX
。
If you are getting errors saying it cannot exceed 30 seconds, this is because your server configuration has forbidden changing that value to anything above 30 seconds.如果您收到错误说它不能超过 30 秒,这是因为您的服务器配置禁止将该值更改为超过 30 秒的任何值。
Quoting the manual set_time_limit引用手册set_time_limit
seconds The maximum execution time, in seconds.
秒最大执行时间,以秒为单位。 If set to zero, no time limit is imposed.
如果设置为零,则没有时间限制。
It maybe unlimited so perhaps for php the limit is just the maximum int value.它可能是无限的,所以对于 php 来说,限制只是最大的int值。
But there could be external factors,
if I remember correctly
suhosin patch have its own maximum execution time
if executed from a web server maybe the server itself have some limit, looking at php sources I've the impression also network timeouts may be a factor.但是可能有外部因素,
如果我没记错的话
,
如果
从 Web 服务器
执行
suhosin补丁有自己的最大执行时间
,也许服务器本身有一些限制,查看php 源我的印象也是网络超时可能是一个因素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.