PHP code example of xxzeroxx / unit-converter

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

    

xxzeroxx / unit-converter example snippets




use UnitConverter\UnitConverter;

$converter = new UnitConverter();

// Length
echo $converter->convertLength(1, 'km', 'm'); // 1000

// Mass
echo $converter->convertMass(1000, 'g', 'kg'); // 1

// Volume
echo $converter->convertVolume(1, 'm³', 'l'); // 1000

// Temperature
echo $converter->convertTemperature(0, 'C', 'F'); // 32

// Area
echo $converter->convertArea(1, 'm²', 'cm²'); // 10000

$converter->convertLength(10, 'invalid', 'm');