<?php
include('includes/header.php');
error_reporting(E_ALL);
echo('<h1>Andrew\'s Counting Timer</h1>');
echo("<h2>Enter a number between 1 and 1000</h2>");
$input = isset($_POST['input']) ? $_POST['input'] : '';
$input = trim($input);
$elapsed = null;
$countTo = null;
if ($input < 1 || $input > 1000) {
$error = "input must be between 1 and 1000.";
} else {
$countTo = $input;
$start = microtime(true);
for ($i = 1; $i <= $input; $i++) {
}
$end = microtime(true);
$elapsed = $end - $start;
}
?>
<form method="POST">
<label for="input">Enter text to search:</label><br>
<input type="text" name="input" id="input" value="">
<input type="submit" value="Start counting">
</form>
<?php
if ($elapsed !== null) {
echo "<p>Counted to <b>" . htmlspecialchars($countTo) . "</b> in <b>"
. number_format($elapsed, 6) . "</b> seconds.</p>";
}
include('includes/footer.php');