當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Localize::number方法代碼示例

本文整理匯總了PHP中Localize::number方法的典型用法代碼示例。如果您正苦於以下問題:PHP Localize::number方法的具體用法?PHP Localize::number怎麽用?PHP Localize::number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Localize的用法示例。


在下文中一共展示了Localize::number方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: input

 /**
  * Sobrecarga do método input incluindo funcionalidades
  * extras, tais como:
  *
  * 1 - Localização automática dos tipos date/datetime e numérico/float
  * 2 - Formatação baseada no TwitterBootstrap
  *
  */
 public function input($fieldName, $options = array())
 {
     $this->setEntity($fieldName);
     $modelKey = $this->model();
     $fieldKey = $this->field();
     $fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey);
     $value = null;
     if (isset($options['value'])) {
         $value = $options['value'];
     } else {
         if (isset($this->request->data[$modelKey][$fieldKey])) {
             $value = $this->request->data[$modelKey][$fieldKey];
         }
     }
     if ((!isset($options['localize']) || $options['localize'] === true) && !empty($value)) {
         switch ($fieldDef['type']) {
             case 'date':
                 $value = Localize::date($value);
                 break;
             case 'datetime':
             case 'timestamp':
                 $value = Localize::datetime($value);
                 break;
             case 'float':
                 $value = Localize::number($value);
                 break;
         }
         $options['value'] = $value;
     }
     if ((!isset($options['keepSeconds']) || $options['keepSeconds'] === true) && $fieldDef['type'] === 'time') {
         $options['value'] = empty($value) || !preg_match('/[0-9]{2}\\:[0-9]{2}(\\:[0-9]{2})?/') ? '00:00' : substr($value, 0, 5);
     }
     if (!isset($options['useBootstrap']) || $options['useBootstrap'] === true) {
         /**
          * @todo Helper não deve estender o BootstrapForm, mas
          * sim usa-lo quando definido.
          */
     }
     return parent::input($fieldName, $options);
 }
開發者ID:radig,項目名稱:rapp,代碼行數:48,代碼來源:RappFormHelper.php

示例2: testUsDecimals

 public function testUsDecimals()
 {
     Localize::setLocale('en_US');
     $this->assertIdentical(Localize::number('1'), '1.00');
     $this->assertIdentical(Localize::number('23'), '23.00');
     $this->assertIdentical(Localize::number('0.5'), '0.50');
     $this->assertIdentical(Localize::number('25.32'), '25.32');
     $this->assertIdentical(Localize::number('25.32', 1), '25.3');
     $this->assertIdentical(Localize::number('25.32', 0), '25');
     $this->assertIdentical(Localize::number('1,300.52'), '1300.52');
     $this->assertIdentical(Localize::number('1,300.52', null, true), '1,300.52');
     $this->assertIdentical(Localize::number('3,965,300.52'), '3965300.52');
     $this->assertIdentical(Localize::number('3,965,300.52', 1, true), '3,965,300.5');
 }
開發者ID:radig,項目名稱:locale,代碼行數:14,代碼來源:LocalizeTest.php


注:本文中的Localize::number方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。