function getmin($min, $xu, $yu, $x1, $y1, $name) { if ($min[1] < triangle($xu, $yu, $x1, $y1)) { return $min; } else { return array($name, triangle($xu, $yu, $x1, $y1)); } }
function triangle($n, $m) { if ($m == 0) { return 0; } echo PHP_EOL; for ($i = $n; $i <= $m; $i += 1) { echo $i . ' '; } return triangle($n, $m - 1) . PHP_EOL; }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/triangle.php"; $app = new Silex\Application(); $app->get("/", function () { return "\n <!DOCTYPE html>\n <html>\n\n <head>\n <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n <title>Enter triangle sides</title>\n </head>\n\n <body>\n <div class='container'>\n <h1>Triangle Sides</h1>\n <p>Enter the three sides of a triangle to find what type of triangle you have.</p>\n <form action='/result'>\n <div class='form-group'>\n <label for='side1'>Enter side one:</label>\n <input id='side1' name='side1' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='side2'>Enter side two:</label>\n <input id='side2' name='side2' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='side3'>Enter side three:</label>\n <input id='side3' name='side3' class='form-control' type='number'>\n </div>\n <button type='submit' class='btn-success'>Submit</button>\n </form>\n </div>\n </body>\n </html>\n "; }); $app->get("/result", function () { $side1 = $_GET["side1"]; $side2 = $_GET["side2"]; $side3 = $_GET["side3"]; $sides = array($side1, $side2, $side3); sort($sides, SORT_NUMERIC); $whatToPrint = ""; if ($sides[0] + $sides[1] < $sides[2]) { $whatToPrint = "Not a valid triangle"; } else { $whatToPrint = "<p>You have a(n) " . triangle($side1, $side2, $side3) . " triangle. </p>"; } return "\n <!DOCTYPE html>\n <html>\n <body>\n <div class='container'>\n {$whatToPrint}\n </div>\n </body>\n </html>\n "; }); return $app;
} function trapezoid($base1, $base2, $height) { return ($base1 + $base2) / 2 * $height; } if ($shape == "square") { $side = readline("Enter Side Length: "); echo "The area is "; echo square($side, $side); echo "\n"; } else { if ($shape == "triangle") { $height = readline("Enter Height: "); $length = readline("Enter Length: "); echo "The area is "; echo triangle($height, $length); echo "\n"; } else { if ($shape == "rectangle") { $length = readline("Enter Length: "); $width = readline("Enter Width: "); echo "The area is "; echo rectangle($length, $width); echo "\n"; } else { if ($shape == "circle") { $radius = readline("Enter Radius: "); echo "The area is "; echo circle($radius); echo "\n"; } else {