本文整理匯總了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);
}