<?php
// Time the script started
$start_time = microtime(true);

// Execution time desired (default is 300 or 5 minutes)
$max_execution_time = 280;
if (!empty($_GET['time'])) {
  $max_execution_time = (int) $_GET['time'];
}

// Shutdown callback function
register_shutdown_function(function() {
  global $start_time;
  $execution_time = microtime(true) - $start_time;
  echo "shutdown function called after $execution_time seconds.\n";
});

// Set the default_socket_timeout
ini_set('default_socket_timeout', $max_execution_time);

// Set the max_execution_time
set_time_limit($max_execution_time);

// Busy wait
for (;;) ;
