示例#1
0
 function testWriteIntAsText()
 {
     $this->assertEquals('four hundred sixty-five million one hundred twenty-three thousand seven hundred eighty-nine', $this->object->writeIntAsText(465123789));
     $this->assertEquals('five hundred', $this->object->writeIntAsText(500));
     $this->assertEquals('one thousand five hundred', $this->object->writeIntAsText(1500));
     $this->assertEquals('two thousand five hundred', $this->object->writeIntAsText(2500));
     $this->assertEquals('ten million ninety-six', $this->object->writeIntAsText(10000096));
 }
示例#2
0
        }
        $text .= '$' . number_format($sum, 2, '.', ',');
        return $text;
    }
}
class Russian extends Localization
{
    function formatMoney($sum)
    {
        $text = number_format($sum, 2, ',', '.') . ' руб.';
        return $text;
    }
    function translate($phrase)
    {
        if ($phrase == 'yes') {
            return 'да';
        }
        if ($phrase == 'no') {
            return 'нет';
        }
        return $phrase;
    }
}
echo '<p>Введите по-английски<br>';
$local = new English();
echo $local->formatMoney(12345678) . '<br>';
echo $local->translate('yes') . '<br>';
echo '<p>Введите по-русски<br>';
$local = new Russian();
echo $local->formatMoney(12345678) . '<br>';
echo $local->translate('yes') . '<br>';
示例#3
0
文件: 1959.php 项目: badlamer/hhvm
<?php

trait Company
{
    public function getName()
    {
        return 'Facebook';
    }
}
class English
{
    use Company;
    public function getHi()
    {
        return "Hi ";
    }
    public function sayHello()
    {
        echo $this->getHi() . $this->getName();
    }
}
$e = new English();
$e->sayHello();
?>

示例#4
0
文件: traits.php 项目: Halfnhav4/pfff
// http://php.net/manual/en/language.oop5.traits.php
// latest spec: http://docs.php.net/traits
trait Company
{
    public function getName()
    {
        return 'Facebook';
    }
}
class Language
{
}
class English extends Language
{
    use Company;
    public function sayHello()
    {
        echo 'Hello' . $this->getName();
    }
}
class Portuguese extends Language
{
    use Company;
    public function sayHello()
    {
        echo 'Oi ' . $this->getName();
    }
}
$o = new English();
$o->sayHello();