我尝试使用
增加 php 中 max_execution_time 的值ini_set('max_execution_time', 108000);
相当于 30 小时。我只是利用这个值来抓取包含大量数据的网站。但是,我遇到了这个 fatal error ,表示最大执行时间不能超过 30 秒。当我将 108000 值更改为 300 时,我的脚本执行了 5 分钟。我想知道 php 中这个东西的最大允许值是多少?
最佳答案
引用 Mjh 评论的正确答案。
解析整数ini值的签名:
ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
因此可以在该字段中输入的最大值为:2147483647
旧答案。
我能找到的唯一线索是这里: https://github.com/php/php-src/blob/master/main/php_ini.h
#define php_ini_long zend_ini_long
这最终会导致: https://github.com/php/php-src/blob/master/Zend/zend_long.h
typedef int64_t zend_long;
这是一个 64 位整数,或者:
−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
编辑:更正。
// PHP x64
typedef int64_t zend_long;
// PHP x86
typedef int32_t zend_long;
所以最大值是PHP_INT_MAX
。
如果您收到错误提示不能超过 30 秒,这是因为您的服务器配置禁止将该值更改为超过 30 秒的任何值。
关于php - php.ini 中 max_execution_time 的最大允许值是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32525590/