PHP code example of orioledev / otus-body-mass-index-calculator

1. Go to this page and download the library: Download orioledev/otus-body-mass-index-calculator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

orioledev / otus-body-mass-index-calculator example snippets




use OrioleDev\OtusBodyMassIndexCalculator\Calculator;

$weight = 60.5; // Weight in kilograms
$height = 170;  // Height in centimeters

$calc = new Calculator();

try {
    echo 'Ваш индекс массы тела: ' . $calc->calculate($weight, $height) . PHP_EOL;   // 20.9
    echo 'Комментарий: ' . $calc->getInfo($weight, $height) . PHP_EOL;               // Здоровый вес
} catch (RuntimeException $e) {
    echo 'Ошибка: ' . $e->getMessage();
}