Set max_execution_time in PHP CLI

前端 未结 4 1858
渐次进展
渐次进展 2020-12-01 04:37

I know that PHP CLI is usually used because of none time limits and primary because it is not using Apache threads/processes.

But is there any way how to explicitly

4条回答
  •  春和景丽
    2020-12-01 04:49

    The documentation says that when running in command line mode, the default is 0 (unlimited). It doesn't say that you cannot override it:

    set_time_limit(10); // this way
    ini_set('max_execution_time', 10); // or this way
    

    Edit: I just tried it myself, and it works as expected.

    F:\dev\www>c:php -f index.php
    PHP Fatal error:  Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3
    
    Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3
    

提交回复
热议问题