You're echoing $totaltime before you've set it...........it needs to come after $totaltime = ($endtime - $starttime);
so a working script would be
<?
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
if($_GET['test'] == 1) {
echo $totaltime;
}
?>
You also need to make sure you're running the script as [filename goes here]?test=1