php.ini中max_execution_time=30并用如下程序测试效果,结果在网页上,无限运行了下去。<?php
        header("Content-Type: text/plain");        while(true)
        {
                echo ini_get('max_execution_time')."\n"; //打印出来的结果就是30
                flush();
                ob_flush();
                sleep(30);
        }
?>

解决方案 »

  1.   

    摘自PHP手册:Warning:
    This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.Note: The set_time_limit() function and the configuration directive max_execution_time  only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real. 
      

  2.   

    ini_set('max_execution_time', 2);
    while(true){
    flush();
    ob_flush();
    sleep(2);
    }报出的信息:第二条Notice: ob_flush() [ref.outcontrol]: failed to flush buffer. No buffer to flush. in D:\documentRoot\test.php on line 8Fatal error: Maximum execution time of 2 seconds exceeded in D:\documentRoot\test.php on line 10
      

  3.   


    我也认为是这个原因,可是无论php.ini或httpd.conf都没有设置安全模式啊。
    php.ini:
    ;
    ; Safe Mode
    ;
    safe_mode = Off