简体   繁体   中英

php throw errors at random lines

PHP throw errors at random lines

error message:

PHP Fatal error: Maximum execution time of 1 second exceeded 

in code we don't have any setting, which sets execution time to one second. And this error occurs on completely random lines. sometimes on simple if statement, sometimes on db query. I can't find any pattern. Maybe someone had similar problem, and had resolved it ?

And this error occurs on completely random lines

It's normal: PHP starts executing code, then fails after one second. So it can be any line, because it does not execute at the same speed all the time (think about I/O, memory, processor load, etc.)

Maybe someone had similar problem, and had resolved it ?

It's a common problem. If you want to fix it you can either:

  • Find where is the actual php.ini file that is user by your server/cli, find the line about max_execution-time and change the value to something like 30. Then reload/restart your server.
  • Or you can add a first line on the first included file with ini_set('max_execution_time', 30); just after the <?php tag. If there is no included file, then add this at the beginning of all your files.

More information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM