本文整理汇总了PHP中sfCultureInfo::getNumberFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP sfCultureInfo::getNumberFormat方法的具体用法?PHP sfCultureInfo::getNumberFormat怎么用?PHP sfCultureInfo::getNumberFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfCultureInfo
的用法示例。
在下文中一共展示了sfCultureInfo::getNumberFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Returns the sfNumberFormatInfo associated with the specified culture.
*
* @param sfCultureInfo the culture that gets the sfNumberFormat property.
* @param int the number formatting type, it should be
* sfNumberFormatInfo::DECIMAL, sfNumberFormatInfo::CURRENCY,
* sfNumberFormatInfo::PERCENTAGE, or sfNumberFormatInfo::SCIENTIFIC
* @return sfNumberFormatInfo sfNumberFormatInfo for the specified culture.
* @see getCurrencyInstance();
* @see getPercentageInstance();
* @see getScientificInstance();
*/
public static function getInstance($culture = null, $type = sfNumberFormatInfo::DECIMAL)
{
if ($culture instanceof sfCultureInfo) {
$formatInfo = $culture->getNumberFormat();
$formatInfo->setPattern($type);
return $formatInfo;
} else {
if (is_string($culture)) {
$sfCultureInfo = new sfCultureInfo($culture);
$formatInfo = $sfCultureInfo->getNumberFormat();
$formatInfo->setPattern($type);
return $formatInfo;
} else {
$sfCultureInfo = new sfCultureInfo();
$formatInfo = $sfCultureInfo->getNumberFormat();
$formatInfo->setPattern($type);
return $formatInfo;
}
}
}
示例2: simplify
}
// ->getDateTimeFormat()
$t->diag('->getDateTimeFormat()');
$c = new sfCultureInfo();
$t->isa_ok($c->getDateTimeFormat(), 'sfDateTimeFormatInfo', '->getDateTimeFormat() returns a sfDateTimeFormatInfo instance');
// ->setDateTimeFormat()
$t->diag('->setDateTimeFormat()');
$d = $c->getDateTimeFormat();
$c->setDateTimeFormat('yyyy');
$t->is($c->getDateTimeFormat(), 'yyyy', '->setDateTimeFormat() sets the sfDateTimeFormatInfo instance');
$c->DateTimeFormat = 'mm';
$t->is($c->getDateTimeFormat(), 'mm', '->setDateTimeFormat() is equivalent to ->DateTimeFormat = ');
// ->getNumberFormat()
$t->diag('->getNumberFormat()');
$c = new sfCultureInfo();
$t->isa_ok($c->getNumberFormat(), 'sfNumberFormatInfo', '->getNumberFormat() returns a sfNumberFormatInfo instance');
// ->setNumberFormat()
$t->diag('->setNumberFormat()');
$d = $c->getNumberFormat();
$c->setNumberFormat('.');
$t->is($c->getNumberFormat(), '.', '->setNumberFormat() sets the sfNumberFormatInfo instance');
$c->NumberFormat = '#';
$t->is($c->getNumberFormat(), '#', '->setNumberFormat() is equivalent to ->NumberFormat = ');
// ->simplify()
$t->diag('->simplify()');
class myCultureInfo extends sfCultureInfo
{
public static function simplify($array)
{
return parent::simplify($array);
}