PHP script Max Execution time problem _php tutorial

Source: Internet
Author: User
Tags web hosting
Most PHP code execution time is not long. But sometimes, such as waiting for a picture to be uploaded, it may take too long to time out.

The default maximum execution time in php.ini is 30 seconds, which is specified by the Max_execution_time variable in php.ini, and if you have a lot of time to do the work, such as sending lots of emails to a large number of senders, or doing heavy data analysis work, The server will forcibly abort the executing program after 30 seconds, how to solve this problem.

The simplest of course is to modify the value of Max_execution_time in php.ini, but not everyone has the right to modify php.ini, such as the use of web hosting developers, the php.ini on the server is used by many sites, so can not be arbitrarily modified.

Another option is to add ini_set (' max_execution_time ', ' 0 ') to the PHP program, and a value of 0 indicates no execution time limit and how long your program needs to run. If your program is still in beta, it is recommended that you set the time limit to a real number so that the error of the program will be removed from the server.

 
  '; flush (); }?>

At the same time can use Ini_get to save the original set of Max_execution_time, after the operation to restore the original set value.

Here is a simple record of the ~

http://www.bkjia.com/PHPjc/752584.html www.bkjia.com true http://www.bkjia.com/PHPjc/752584.html techarticle Most PHP code execution time is not long. But sometimes, such as waiting for a picture to be uploaded, it may take too long to time out. The default maximum execution time in php.ini is ...

  • 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.