60秒后PHP无限循环未终止

I created an infinite PHP while loop which incremented a variable then echoed:

$num = 1;

while($num >0) {
echo $num . "<br/>";
$num++;
}

I was expecting this to be killed/terminated after 60 seconds as the setting in php.ini are as follows:

max_execution_time  60  60
max_input_time  60  

Sorry if I'm wrong but I expected to see the job killed in the browser (no new echos!)...

Can anyone give me more information on infinite PHP jobs running and when they are actually killed on the server?

You are confusing execution time with wall clock time. They are not the same thing. The processor is using very little execution time on each loop of your code. It will eventually time you out but it's going to take a lot longer than a minute.

Think of it this way, your processor may be running at 2GHz. How many instructions do you think it takes to do one of your loops? The time on echo is big (i.e. slow) and it doesn't count toward processor execution time.

//using set_time_limit 
// starting php code here
echo "starting...
"; 
// set_time_limit(10); //either would work
ini_set("max_execution_time", 10); //either would work


function doSomeExpensiveWork($currentTime){
  for ($r = 0; $r < 100000; $r++){ 
    $x =  tan(M_LNPI+log(ceil(  date("s")*M_PI*M_LNPI+100))); 
  } 
}

try{
  while(true)
  { 
      $currentTime = date("H:m:s"); 
      echo $currentTime, "
";
      doSomeExpensiveWork($currentTime);
  } 
} catch (Exception $e) {
  //echo 'Caught exception: ',  $e->getMessage(), "
";
}
echo "this will not be executed! $x"; 
// code end