Php max_execution_time execution time

Source: Internet
Author: User

Php. the default execution time in ini is 30 seconds. the max_execution_time variable in ini specifies that if you have a job that takes a lot of time to complete, such as sending a lot of emails to a large number of recipients, or performing heavy data analysis, the server will forcibly stop the program being executed 30 seconds later. How can this problem be solved.
The simplest of course is to modify php. max_execution_time value in ini, but not everyone has the right to modify php. ini, for example, developers who use web hosting, php on the server. ini is used by many websites, so it cannot be modified at will.
Another method is to add ini_set ('max _ execution_time ', '0') to the PHP program. The value 0 indicates that there is no execution time limit, and your program will run as long as it takes. If your program is still in the test phase, we recommend that you set a real number for the time limit to avoid program errors that take the server away.
Copy codeThe Code is as follows:
<? Php
// Max_execution_time = 100;
Ini_set ("max_execution_time", 1); // you can use this function to set
For ($ I = 1; I I <100000; $ I ++)
{
Echo "No. {$ I} \ n ";
Echo '<br/> ';
Flush ();
}
?>

At the same time, you can use ini_get to save the previously set max_execution_time and reply to the original set value after the operation.
Here is a simple record ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.