PHP code example of soandso / units

1. Go to this page and download the library: Download soandso/units 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/ */

    

soandso / units example snippets




use Soandso\Units\Bootstrap;

Bootstrap::init();

use Soandso\Units\Registry\Quantity;
use Soandso\Units\Unit;

$temperature = Quantity::get(Unit::TEMPERATURE);

$temperature->name;
$temperature->description;
$temperature->class;

$temperature->units;

use Soandso\Units\Value\Temperature;

Temperature::c(20)
    ->toF()
    ->value(); //68

use Soandso\Units\Value\Temperature;
use Soandso\Units\Enum\Temperature as TemperatureUnit;

Temperature::c(20)
    ->convertTo(TemperatureUnit::F)
    ->value(); //68

Temperature::c(20);
Temperature::f(68);
Temperature::k(293.15);

$temperature = Temperature::c(20);

$temperature->value();
$temperature->unit()->value;

use Soandso\Units\Enum\Unit;
use Soandso\Units\Registry\Quantity;

$quantity = Quantity::get(Unit::PRESSURE);

use Soandso\Units\Registry\Quantity;

$all = Quantity::all();

use Soandso\Units\Value\Temperature;

$celsius = Temperature::c(20);

$celsius->toF()->value(); //68
$celsius->toK()->value(); //293.15
text
Temperature
Air temperature units
Soandso\Units\Value\Temperature

[
    "C",
    "F",
    "K"
]