本文整理汇总了PHP中Money\Money::usd方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::usd方法的具体用法?PHP Money::usd怎么用?PHP Money::usd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money\Money
的用法示例。
在下文中一共展示了Money::usd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFormat
public function testFormat()
{
$m1 = Money::usd(123456);
// $1234.56
$m2 = Money::usd(123400);
// $1234.00
$this->assertEquals('$1,234.56', $m1->format());
$this->assertEquals('$1,234~56', $m1->format(array('decimal_mark' => '~')));
$this->assertEquals('$1_234.56', $m1->format(array('thousands_separator' => '_')));
$this->assertEquals('$1,234.56 USD', $m1->format(array('with_currency' => true)));
$this->assertEquals('<span class="symbol">$</span><span class="amount">1,234.56</span><span class="currency">USD</span>', $m1->format(array('with_currency' => true, 'html' => true)));
$this->assertEquals('$1,234', $m1->format(array('no_cents' => true)));
$this->assertEquals('$1,234.56', $m1->format(array('no_cents_if_whole' => true)));
$this->assertEquals('$1,234', $m2->format(array('no_cents_if_whole' => true)));
$this->assertEquals('$1,234.56', $m1->format(array('no_cents_if_whole' => false)));
$this->assertEquals('$1,234.00', $m2->format(array('no_cents_if_whole' => false)));
$this->assertEquals('1,234.56$', $m1->format(array('symbol_position' => 'after')));
}
示例2:
<?php
require_once 'src/money.php';
use Money\Money;
$m = Money::usd(100);
print_r($m->format(array('disambiguate' => true)));