What are common methods for creating a BMI calculator in PHP?

One common method for creating a BMI calculator in PHP is to take user input for weight and height, calculate the BMI using the formula (BMI = weight / (height * height)), and then display the result to the user. This can be achieved by creating a simple form in HTML for user input and using PHP to process the input and calculate the BMI.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $weight = $_POST['weight'];
    $height = $_POST['height'];

    $bmi = $weight / ($height * $height);

    echo "Your BMI is: " . $bmi;
}
?>

<form method="post">
    <label for="weight">Weight (kg):</label>
    <input type="text" name="weight" id="weight" required><br>

    <label for="height">Height (m):</label>
    <input type="text" name="height" id="height" required><br>

    <button type="submit">Calculate BMI</button>
</form>