<?php require_once 'bin/battle.php'; if (isset($_GET['army1']) && isset($_GET['army2']) && is_numeric($_GET['army1']) && is_numeric($_GET['army2'])) { $battle = new battle(array($_GET['army1'], $_GET['army2'])); //start battle echo 'Army' . $battle->winner() . ' won'; } else { echo "Set army1 and army2 query string (number)"; }
}"> </script> </head> <body> <?php $time_start = microtime(true); if (isset($_GET['army1']) && isset($_GET['army2']) && is_numeric($_GET['army1']) && is_numeric($_GET['army2'])) { $battle = new battle(array($_GET['army1'], $_GET['army2'])); //start battle $time_end = microtime(true); $execution_time = (int) (($time_end - $time_start) * 1000); ?> <div id="score"> <p class="title"> Army<?php echo $battle->winner(); ?> won </p> <p class="text"> <?php echo $battle->winnerCount(); ?> warriors survived </p> <p class="text"> The battle lasted for <?php echo $execution_time; ?> milliseconds </p>