碰到页面程序执行超时时会提醒Fatal error: Maximum execution time of 300 seconds exceeded 是因为程序执行时间超过了最大允许执行时间,解决办法我总结了好几个大家选择适合自己的吧.
对于函数我们可以常用下面方法,直接给函数设置超时时间来操作,代码如下:
declare(ticks = 1); function a(){ sleep(10); echo "a finishi "; } function b(){ echo "Stop "; } function c(){ usleep(100000); } function sig(){ throw new Exception; } try{ pcntl_alarm(1); pcntl_signal(SIGALRM, "sig"); a(); pcntl_alarm(0); }catch(Exception $e){ echo "timeout "; } b(); a(); b();
对于文件或程序代码可使用set_time_limit只是设置你的PHP程序的超时时间.
解决方法:
1.修改php.ini文件,代码如下:
max_execution_time = 30; // Maximum execution time of each script, in seconds 原值30秒,你可以改大点.
改完后记得重启php,该方法改了后对所有程序生效.
2.修改你的程序,在你需要耗时超过默认值(30秒)的脚本中,加入代码:
set_time_limit(300); // 最大执行时间这里设置300秒
设置成0表示不限时.
本文地址:
转载随意,但请附上文章地址:-)

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
