soneritics/currency

货币类,用于转换和显示特定货币的价格。

dev-master 2015-02-19 20:42 UTC

This package is auto-updated.

Last update: 2024-09-23 18:18:08 UTC


README

Build Status Coverage Status License

介绍

货币转换和格式化价格标签显示。

最低要求

  • PHP 5.5+

特性

  • 显示格式化的价格;$ 1.99 或 € 1,99
  • 货币转换

示例

$price = (new Price)
    ->addCurrency('euro', new Currency('', ',', '.'));
    ->addCurrency('usd', new Currency('$', '.', ',', 1.1388));

echo $price->convert(1, 'euro', 'usd'); // 1.1388
echo $price->convert(1, 'usd', 'euro'); // 0.87812

echo $price->show(1); // € 1,00
echo $price->show(1, 'euro'); // € 1.00
echo $price->show(1, 'usd'); // $ 1.39
echo $price->show(1, 'euro', 'usd'); // € 0.88
echo $price->show(1, 'usd', 'euro'); // $ 1.39