<?php
echo '<html><body>';
set_time_limit(1);
$i = 0;
while(++$i < 100000001){
if($i % 100000 == 0){
echo $i / 100000, "<br/>\n";
}
}
echo "done.<br/>\n";
// will not echo 'done.'.
?>
The above code keeps echoing echo $i / 100000, "<br/>\n";
till 1 second and then stops the execution since I have used set_time_limit(1);
But I want it to echo only if the complete loop gets executed within 1 sec and else instead of echoing I want to pop up or display a message that says timeout or cannot perform execution in 1 sec
.
Is it possible to achieve this somehow in PHP?