How Can I Calculate The Area of Triangle Using PHP

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

In PHP for calculating Area of a triangle we use this formula (base * height) / 2 = Area .So today we discuss how to do it.

How Can I Calculate The Area of Triangle Using PHP

Complete Code For Calculating The Area of Triangle Using PHP

<!DOCTYPE html>
<html>
<head>
    <title>How Can I Calculate The Area of Triangle Using PHP</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
    body {
        background: black;
    }
</style>
<body>
<body>
<div class="container">
    <br/><br/>
    <div class="text-center">
        <h1 id="color" style="color: white;">Calculating The Area of Triangle Using PHP</h1>
    </div>

    <div class="well">
        <form action="" method="post" >
            <label>Enter Base</label><br>
            <input type="text" name="base"  value=""><br><br>
            <label>Enter Height</label><br>
            <input type="text" name="height" value=""><br><br>
            <input type="submit" value="submit" class="btn btn-success" name="submit">
        </form>

        <?php
        if(isset($_POST['submit']))
        {
            $base = $_POST['base'];
            $height = $_POST['height'];
            $area = ($base*$height) / 2;
            echo "The area of a triangle with base as $base and height as $height is $area";
        }
        ?>
    </div>
</div>
</body>
</html>

Related Post