Skip to content

Instantly share code, notes, and snippets.

@mithereal
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mithereal/ba5153c7453abd6916a7 to your computer and use it in GitHub Desktop.
Save mithereal/ba5153c7453abd6916a7 to your computer and use it in GitHub Desktop.
detect php max timeout limit on shared hosting
<?php
$max_timeout = 600;
$start = time();
register_shutdown_function('shutdown',$start);
for(;;)
{
$finish = time();
$total = $finish - $start;
if($total >= $max_timeout)
{
exit;
}
}
function shutdown($start)
{
$finish = time();
$total = $finish - $start;
// Store $total in DB
echo json_encode($total);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment