php max_execution_time执行时间问题
php.ini 中缺省的最长执行时间是 30 秒,这是由 php.ini 中的 max_execution_time 变量指定,倘若你有一个需要颇多时间才能完成的工作,例如要发送很多电子邮件给大量收件者,或者要进行繁重的数据分析工作,服务器会在 30 秒后强行中止正在执行的程序,如何解决这个问题呢。
最简单当然是修改 php.ini 中 max_execution_time 的数值,不过不是所有人都有权修改 php.ini,例如使用网页寄存的开发人员,服务器上的 php.ini 由很多网站共同使用,所以不能随意修改。
另一个办法是在 PHP 程序中加入 ini_set('max_execution_time', '0'),数值 0 表示没有执行时间的限制,你的程序需要跑多久便跑多久。若果你的程序仍在测试阶段,推荐你把时限设置一个实数,以免程序的错误把服务器当掉。
复制代码 代码如下:
//max_execution_time=100;
ini_set("max_execution_time", 1); //用此function才能真正在运行时设置
for($i=1; $i{
echo "No. {$i}\n";
echo '
';
flush();
}
?>
同时可以使用ini_get把原来设置的max_execution_time保存下来,在进行完操作时回复原来的设定值。
在这里简单记录下~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools
