php PHP忽略我的max_execution_time
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7656031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Ignoring my max_execution_time
提问by Muhammad Resna Rizki Pratama
I have some task in my script that is about converting video with ffmpeg . I do this with codeigniter 2.0.3 and locate the script at libraries and use shell_exec() to run ffmpeg.
我的脚本中有一些关于使用 ffmpeg 转换视频的任务。我使用 codeigniter 2.0.3 执行此操作,并在库中找到脚本并使用 shell_exec() 运行 ffmpeg。
There are 3 tasks in my php script.
我的 php 脚本中有 3 个任务。
- Upload File
- Convert video to .flv
- Generate thumb
- Save to db.
- 上传文件
- 将视频转换为 .flv
- 生成拇指
- 保存到数据库。
When I upload file, my php script start to convert my uploaded video. But when converting is end about over 5 minutes. Its not continue to generate thumb. And Its say
当我上传文件时,我的 php 脚本开始转换我上传的视频。但是当转换结束大约 5 分钟。它不会继续生成拇指。它说
PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\AppServ\www\mis\application\libraries\my_video_utility.php on line 102, referer: http://localhost/mis/test/
PHP 致命错误:在 C:\AppServ\www\mis\application\libraries\my_video_utility.php 的第 102 行中超出了 300 秒的最大执行时间,引用:http://localhost/mis/test/
I have set my max_execution time, max_input_time, etc to 3600 in php.ini also add set_time_limit() and set_ini() in my php script. But, its still get error.
我已在 php.ini 中将 max_execution time、max_input_time 等设置为 3600,还在我的 php 脚本中添加了 set_time_limit() 和 set_ini()。但是,它仍然会出错。
But, when I uploaded short video, its done.
但是,当我上传短视频时,它完成了。
回答by Muhammad Resna Rizki Pratama
Ok. I do this my self. I have contacted my teacher. There is a something that CodeIgniter not include this in their documentation.
好的。我自己做。我已经联系了我的老师。CodeIgniter 的文档中没有包含这一点。
At line 103 in system/core/CodeIgniter.php
在 system/core/CodeIgniter.php 中的第 103 行
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
@set_time_limit(300);
}
I try to change the value and it works.
我尝试更改该值并且它有效。
回答by joni jones
Solution to change set_time_limit()
function in CodeIgniter.php is works, but I'm think it's not good idea to change framework's core files.
set_time_limit()
在 CodeIgniter.php 中更改函数的解决方案是可行的,但我认为更改框架的核心文件不是一个好主意。
I'm found another decision, you can call set_time_limit()
where you need and it will be overlapp setting of time limit in CodeIgniter.php.
我发现了另一个决定,你可以set_time_limit()
在你需要的地方打电话,这将是 CodeIgniter.php 中时间限制的重叠设置。
回答by avatarofhope2
Codeigniter 2 has the set_time_limit function run with 300. After upgrading to Codeigniter 3, one thing started failing. After viewing this post, I realized that the set_time_limit call was removed in 3, so you may have to add the code in the accepted answer to your particular problem code. I would not recommend adding it back into the Codeigniter.php
Codeigniter 2 的 set_time_limit 函数以 300 运行。升级到 Codeigniter 3 后,一件事开始失败。查看此帖子后,我意识到 set_time_limit 调用已在 3 中删除,因此您可能必须将接受的答案中的代码添加到您的特定问题代码中。我不建议将它添加回 Codeigniter.php