Home >Backend Development >PHP Tutorial >[PHP]Maximum execution time of 30 seconds exceeded

[PHP]Maximum execution time of 30 seconds exceeded

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:30:28912browse

# 前言在使用`PHP`渲染页面页面的时候,如果程序处理的时间特别久,超过配置文件(php.ini)设置的超时时间,就会出现如下提示:>Maximum execution time of 30 seconds exceeded例如:导入大量数据到数据库中;请求资源时间过长……# 问题PHP程序超时发生错误提示怎么办?# 方法* 直接修改配置文件(php.ini)[超时]```#默认的最大执行时间是30s,可根据自己的需求做修改#如果是0,即永不过期max_execution_time = 30;```* 间接修改配置信息[超时]在php执行文件中加入如下代码:``` phpset_time_limit(0);```* 刷新输出缓冲[内存超限]  1. 在循环当中做延迟执行:加入函数`sleep(time)`  2. 输出缓冲:同时使用`ob_flush()`和`flush()`函数将数据发送到浏览器``` php<?phpfor ($i=0; $i < 10000; $i++) {	echo "hello ".printf('%05s',$i).'<br/>';	ob_flush();	flush();}```

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:一个字符串的求教Next article:PHP 学习笔记