当前位置: 首页>>代码示例>>PHP>>正文


PHP Locale::toString方法代码示例

本文整理汇总了PHP中Zend\Locale\Locale::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::toString方法的具体用法?PHP Locale::toString怎么用?PHP Locale::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Locale\Locale的用法示例。


在下文中一共展示了Locale::toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testTerritoryToGetLocale

    /**
     * @ZF-9488
     */
    public function testTerritoryToGetLocale()
    {
        $value = Locale::findLocale('US');
        $this->assertEquals('en_US', $value);

        $value = new Locale('US');
        $this->assertEquals('en_US', $value->toString());

        $value = new Locale('TR');
        $this->assertEquals('tr_TR', $value->toString());
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:14,代码来源:LocaleTest.php

示例2: equals

 /**
  * Returns true if both locales are equal
  *
  * @param  \Zend\Locale\Locale $object Locale to check for equality
  * @return boolean
  */
 public function equals(Locale $object)
 {
     if ($object->toString() === $this->toString()) {
         return true;
     }
     return false;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:Locale.php

示例3: testSetOption

 /**
  * test setOption
  * expected boolean
  */
 public function testSetOption()
 {
     $this->assertEquals(8, count(Format::setOptions(array('format_type' => 'php'))));
     $this->assertTrue(is_array(Format::setOptions()));
     try {
         $this->assertTrue(Format::setOptions(array('format_type' => 'xxx')));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     try {
         $this->assertTrue(Format::setOptions(array('myformat' => 'xxx')));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     $format = Format::setOptions(array('locale' => 'de', 'number_format' => Format::STANDARD));
     $test = Cldr::getContent('de', 'decimalnumber');
     $this->assertEquals($test, $format['number_format']);
     try {
         $this->assertFalse(Format::setOptions(array('number_format' => array('x' => 'x'))));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     $format = Format::setOptions(array('locale' => 'de', 'date_format' => Format::STANDARD));
     $test = Format::getDateFormat('de');
     $this->assertEquals($test, $format['date_format']);
     try {
         $this->assertFalse(Format::setOptions(array('date_format' => array('x' => 'x'))));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     try {
         $this->assertFalse(is_array(Format::setOptions(array('fix_date' => 'no'))));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     $format = Format::setOptions(array('locale' => Format::STANDARD));
     $locale = new Locale();
     $this->assertEquals($locale->toString(), $format['locale']);
     try {
         $this->assertFalse(is_array(Format::setOptions(array('locale' => 'nolocale'))));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     try {
         $this->assertFalse(is_array(Format::setOptions(array('precision' => 50))));
         $this->fail("exception expected");
     } catch (InvalidArgumentException $e) {
         // success
     }
     // test interaction between class-wide default date format and using locale's default format
     try {
         $result = array('date_format' => 'MMM d, y', 'locale' => 'en_US', 'month' => '7', 'day' => '4', 'year' => '2007');
         Format::setOptions(array('format_type' => 'iso', 'date_format' => 'MMM d, y', 'locale' => 'en_US'));
         // test setUp
     } catch (InvalidArgumentException $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date_format with global locale
         $this->assertSame($result, Format::getDate('July 4, 2007'));
     } catch (InvalidArgumentException $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date_format with given locale
         $this->assertSame($result, Format::getDate('July 4, 2007', array('locale' => 'en_US')));
     } catch (InvalidArgumentException $e) {
         $this->fail("exception expected");
     }
     try {
         // sets a new global date format
         Format::setOptions(array('date_format' => 'M-d-y'));
     } catch (InvalidArgumentException $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date format with given locale
         // but this date format differs from the original set... (MMMM d, yyyy != M-d-y)
         $expected = Format::getDate('July 4, 2007', array('locale' => 'en_US'));
         $this->assertSame($expected['year'], $result['year']);
         $this->assertSame($expected['month'], $result['month']);
         $this->assertSame($expected['day'], $result['day']);
     } catch (InvalidArgumentException $e) {
         $this->fail("exception expected");
     }
     try {
         // the following should not be used... instead of null, Locale::ZFDEFAULT should be used
         // uses given local with standard format from this locale
         $this->assertSame($result, Format::getDate('July 4, 2007', array('locale' => 'en_US', 'date_format' => null)));
     } catch (InvalidArgumentException $e) {
//.........这里部分代码省略.........
开发者ID:alab1001101,项目名称:zf2,代码行数:101,代码来源:FormatTest.php


注:本文中的Zend\Locale\Locale::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。