gpt4 book ai didi

PHP- 无法更改 xampp 中的 max_execution_time

转载 作者:可可西里 更新时间:2023-11-01 12:35:04 27 4
gpt4 key购买 nike

我已经尝试了所有方法来更改 php 爬虫脚本的 max_execution_time,以便它可以运行无限长的时间。

我已将 php.ini 文件设置 max_execution_time 更改为 0100000000 但没有更改

我还尝试使用 ini_set('max_execution_time', 0);

从 php 脚本本身设置它

所有 php 脚本都抛出相同的错误 fatal error :超过 3000 秒的最大执行时间,我可能遗漏了什么以及如何确保没有最大执行时间限制?

php 脚本

<?php
ini_set('MAX_EXECUTION_TIME', -1);
error_reporting(E_ALL); // turn on all errors, warnings and notices for easier debugging
//ini_set('max_execution_time', 123456);
ini_set('max_input_time', -1);
ini_set('memory_limit', '512M');
set_time_limit(0);
date_default_timezone_set('Europe/London');

/*code which scrapes websites*/

?>

phpinfo()

max_execution_time  0   0
max_input_time -1 -1

最佳答案

尝试在 php 中关闭安全模式,然后尝试下面的代码

if( !ini_get('safe_mode') ){ 
set_time_limit(0); //this won't work if safe_mode is enabled.
}

这应该允许您无限期地运行脚本。

在 Apache 中,您可以通过 .htaccess 使用此行更改最大执行时间

php_value max_execution_time 200

set_time_limit() php manual ref.

关于PHP- 无法更改 xampp 中的 max_execution_time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11284731/

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