表示货币价值的值对象(使用货币的最小单位)。
**此项目已被放弃。**它最初只是用作 PHPUnit 功能等的示例,并不适用于生产环境。我很抱歉没有明确说明这一点。请转而查看 moneyphp/money。
{ "require": { "sebastian/money": "^1.6" } }
use SebastianBergmann\Money\Currency;
use SebastianBergmann\Money\Money;
// Create Money object that represents 1 EUR
$m = new Money(100, new Currency('EUR'));
// Access the Money object's monetary value
print $m->getAmount();
// Access the Money object's monetary value converted to its base units
print $m->getConvertedAmount();上述代码生成了下面所示的输出: 1.00
use SebastianBergmann\Money\Currency;
use SebastianBergmann\Money\Money;
// Create Money object that represents 12.34 EUR
$m = Money::fromString('12.34', new Currency('EUR'))
// Access the Money object's monetary value
print $m->getAmount();上述代码生成了下面所示的输出:
use SebastianBergmann\Money\EUR;
// Create Money object that represents 1 EUR
$m = new EUR(100);
// Access the Money object's monetary value
print $m->getAmount();上述代码生成了下面所示的输出:
请注意,没有 Money 的子类专用于土耳其里拉,因为 TRY 在 PHP 中不是有效的类名。
php 使用塞巴斯蒂安
100 1234 100
暂无开放 Issues,或尚未同步最近议题。