PHP code example of phospr / quantity

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

    

phospr / quantity example snippets


$weight = new Weight(new Fraction(14), new Uom('OZ'));

$pounds = new Uom('LB');
$pounds = Uom::LB();

$weight = new Weight(new Fraction(10), new Uom('LB'));
$weight = new Weight(new Fraction(10), Uom::LB());
$weight = Weight::LB(10);

echo Weight::LB(2)->to(Uom::OZ()); // 32

echo Weight::OZ(28)->to(Uom::LB()); // 1 3/4 LB