This is my first time asking a question in this website so please bear with me. I got a script from another website for testing internet connection speed and added if else statement. If the speed is more than 500, it will redirect to a specific page. For some reasons, I can’t make it to work. I have added the ob_start(); before the <html> tag and also added ob_end_flush(); after the </html> tag. I have added the code below in between my body tags.
$kb=512;
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
$intspeed = round($kb / $deltat, 0);
echo $intspeed; //just to check if $intspeed has a value
if ($intspeed > 500) {
header("Location: test.php");
exit();
} else {
header('Location: falcons/index.php');
exit();
}
Remove the
flush();calls. Also, ensure that this code is betweenob_start()andob_end_flush(), not before or after (and also that nothing else is output before this code).