Skip to content

tankotun/tConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 

Repository files navigation

tConverter

A simple PHP unit converter.

Developed by @tankotun

Supported Units: Weight, Length.
But if you want to add another units, you can it by $units array in tConverter class.


First, require and start class.

```php // Require require "tConverter.class.php";

// Then, start the class. $tConverter = new tConverter();


<h3>How to convert?</h3>
```php
$result = $tConverter->convert(
  'length',    // This is unit type. We chose length. (or you can choose 'weight')
  array('2', 'km'),    // From... 2 kilometers
  'm'   // To meters...
);

echo 'Result: ' . $result;

Print:

Result: 2000

Use with Exception

```php try {

$result = $tConverter->convert( 'length', // This is unit type. We chose length. array('2', 'km'), // From... 2 kilometers 'm' // To meters... );

echo 'Result: ' . $result;

} catch (tConverterException $e) {

echo $e->getMessage();

}

<i>Exception catches posted empty units and invalid numerics.</i>

<h3>Units List</h3>

Length        | Weight
------------- | -------------
pikometre     |miligram
nanometre     |gram
milimetre     |kilogram
santimetre    |ton
desimetre     |
metre         |
dekametre     |
hektometre    |
kilometre     |
gigametre     |
terametre     |


<br/>
God bless open source programmers.

About

A simple PHP unit converter class.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages