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

[PHP]Maximum execution time of 30 seconds exceeded

WBOY
Release: 2016-06-20 12:30:28
Original
878 people have browsed it

# 前言在使用`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();}```
Copy after login

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template