本文整理汇总了PHP中util::number_to_word方法的典型用法代码示例。如果您正苦于以下问题:PHP util::number_to_word方法的具体用法?PHP util::number_to_word怎么用?PHP util::number_to_word使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::number_to_word方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_number_to_word
public function test_number_to_word()
{
$this->assertEquals('one', util::number_to_word(1));
$this->assertEquals('five', util::number_to_word(5));
$this->assertEquals('fifteen', util::number_to_word(15));
$this->assertEquals('one hundred and thirty-six', util::number_to_word(136));
$this->assertEquals('negative twelve', util::number_to_word(-12));
$this->assertEquals('zero point eight', util::number_to_word(0.8));
}
示例2: test_number_to_word
public function test_number_to_word()
{
try {
util::number_to_word('junk data');
$this->fail('Accepted junk data');
} catch (\LogicException $e) {
$this->assertEquals('Not a number', $e->getMessage());
}
// Partially numeric.
$this->assertEquals('', util::number_to_word('1a'));
// Decimals
$this->assertEquals('five point zero five', util::number_to_word('5.05'));
$this->assertEquals('zero point eight', util::number_to_word(0.8));
// Integers
$this->assertEquals('positive one', util::number_to_word('+1'));
$this->assertEquals('negative twelve', util::number_to_word(-12));
$this->assertEquals('one', util::number_to_word(1));
$this->assertEquals('five', util::number_to_word(5));
$this->assertEquals('fifteen', util::number_to_word(15));
$this->assertEquals('twenty-one', util::number_to_word(21));
$this->assertEquals('thirty-two', util::number_to_word(32));
$this->assertEquals('forty-three', util::number_to_word(43));
$this->assertEquals('fifty-four', util::number_to_word(54));
$this->assertEquals('sixty-six', util::number_to_word(66));
$this->assertEquals('seventy-seven', util::number_to_word(77));
$this->assertEquals('eighty-eight', util::number_to_word(88));
$this->assertEquals('ninety-nine', util::number_to_word(99));
$this->assertEquals('one hundred and thirty-six', util::number_to_word(136));
$this->assertEquals('ten', util::number_to_word(10));
$this->assertEquals('twenty', util::number_to_word(20));
$this->assertEquals('thirty', util::number_to_word(30));
$this->assertEquals('forty', util::number_to_word(40));
$this->assertEquals('fifty', util::number_to_word(50));
$this->assertEquals('sixty', util::number_to_word(60));
$this->assertEquals('seventy', util::number_to_word(70));
$this->assertEquals('eighty', util::number_to_word(80));
$this->assertEquals('ninety', util::number_to_word(90));
$this->assertEquals('eleven', util::number_to_word(11));
$this->assertEquals('thirteen', util::number_to_word(13));
$this->assertEquals('fourteen', util::number_to_word(14));
$this->assertEquals('fifteen', util::number_to_word(15));
$this->assertEquals('sixteen', util::number_to_word(16));
$this->assertEquals('seventeen', util::number_to_word(17));
$this->assertEquals('eighteen', util::number_to_word(18));
$this->assertEquals('nineteen', util::number_to_word(19));
$this->assertEquals('one thousand', util::number_to_word(1000));
$this->assertEquals('one million', util::number_to_word(1000000));
$this->assertEquals('one billion', util::number_to_word(1000000000));
$this->assertEquals('one trillion', util::number_to_word(1000000000000.0));
$this->assertEquals('one quadrillion', util::number_to_word('1000000000000000'));
$this->assertEquals('one quintrillion', util::number_to_word('1000000000000000000'));
$this->assertEquals('one sextillion', util::number_to_word('1000000000000000000000'));
$this->assertEquals('one septillion', util::number_to_word('1000000000000000000000000'));
$this->assertEquals('one octillion', util::number_to_word('1000000000000000000000000000'));
$this->assertEquals('one nonillion', util::number_to_word('1000000000000000000000000000000'));
$this->assertEquals('one decillion', util::number_to_word('1000000000000000000000000000000000'));
$this->assertEquals('one', util::number_to_word('1000000000000000000000000000000000000000000'));
}