1. Go to this page and download the library: Download ayeo/temperature 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/ */
ayeo / temperature example snippets
use Temperature\Factory\DefaultFactory as TemperatureFactory;
$factory = new TemperatureFactory();
$temperature = $factory->build(63, 'F');
$temperature; //63 °F
$temperature->convert('C'); //17.2222222222 °C
$temperature->convert('C')->setPrecision(2); //17.22 °C
use Temperature\Formatter\StandardFormatter;
$formatter = new StandardFormatter();
$formatter->setDecimalSeperator(",");
$formatter->setPrecision(2);
$formatter->setShowSymbolMode(false);
$factory->setFormatter($formatter);
$factory->build(10.50, 'C'); //10,50
$factory->build(100, 'K'); //100
use \Temperature\Scales\Scale\AbstractScale;
class C2Scale extends AbstractScale
{
const SYMBOL = "C2";
/**
* @return float
*/
function getValueInCelsius()
{
return $this->value / 2;
}
/**
* @param $celsius
*/
function setValueInCelsius($celsius)
{
$this->value = $celsius * 2;
}
}
$factory->getSupportedScales()->addSupportedType('C2', 'C2Scale');
$factory->build(100, 'C')->convert('C2'); //200 C2
$factory->build(50, 'K')->convert('C2'); //-446 C2
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.