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


PHP Zend_Locale_Format::isFloat方法代碼示例

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


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

示例1: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a floating-point value
  * 
  * @todo http://framework.zend.com/issues/browse/ZF-2895
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     if (!Zend_Locale_Format::isFloat($valueString, $this->_options)) {
         $this->_error();
         return false;
     }
     return true;
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:19,代碼來源:Float.php

示例2: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a floating-point value
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     try {
         if (!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
             $this->_error();
             return false;
         }
     } catch (Zend_Locale_Exception $e) {
         $this->_error();
         return false;
     }
     return true;
 }
開發者ID:H38uS,項目名稱:Impulsion,代碼行數:23,代碼來源:Float.php

示例3: isValid

 public function isValid($value)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         $this->_error(self::INVALID);
         return false;
     }
     if (is_float($value)) {
         return true;
     }
     $value = str_replace('.', ',', $value);
     $this->_setValue($value);
     try {
         if (!Zend_Locale_Format::isFloat($value, array('locale' => 'pl'))) {
             $this->_error(self::NOT_FLOAT);
             return false;
         }
     } catch (Zend_Locale_Exception $e) {
         $this->_error(self::NOT_FLOAT);
         return false;
     }
     return true;
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:22,代碼來源:UniversalFloat.php

示例4: testIsFloat

 /**
  * test isFloat
  * expected boolean
  */
 public function testIsFloat()
 {
     $this->assertTrue( Zend_Locale_Format::isFloat('-1.234.567,12345',  array('locale' => 'de_AT')));
     $this->assertFalse(Zend_Locale_Format::isFloat('textwithoutnumber', array('locale' => 'de_AT')));
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:9,代碼來源:FormatTest.php

示例5: testShortNotation

 public function testShortNotation()
 {
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $this->assertEquals('0,75', Zend_Locale_Format::toNumber(0.75, array('locale' => 'de_DE', 'precision' => 2)));
     $this->assertTrue(Zend_Locale_Format::isNumber(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $options = array('locale' => 'ar_QA');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $this->assertTrue(Zend_Locale_Format::isFloat(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0, Zend_Locale_Format::getInteger(0.1234567));
     $options = array('locale' => 'de');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.123, array('locale' => 'de')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.12345, $options));
     $this->assertFalse(Zend_Locale_Format::isInteger(',12345', array('locale' => 'de_AT')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,567', Zend_Locale_Format::toNumber(0.5669999999999999, $options));
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:31,代碼來源:FormatTest.php

示例6: testIsFloat

 /**
  * test isFloat
  * expected boolean
  */
 public function testIsFloat()
 {
     $this->assertEquals(Zend_Locale_Format::isFloat('-1.234.567,12345', array('locale' => 'de_AT')), true, "true expected");
     $this->assertEquals(Zend_Locale_Format::isFloat('textwithoutnumber', array('locale' => 'de_AT')), false, "false expected");
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:9,代碼來源:FormatTest.php

示例7: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a floating-point value
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         $this->_error(self::INVALID);
         return false;
     }
     $this->_setValue($value);
     if ($this->_locale === null) {
         $locale = localeconv();
         $valueFiltered = str_replace($locale['thousands_sep'], '', (string) $value);
         $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);
         if (strval(floatval($valueFiltered)) != $valueFiltered) {
             $this->_error(self::NOT_FLOAT);
             return false;
         }
     } else {
         try {
             if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) && !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
                 $this->_error(self::NOT_FLOAT);
                 return false;
             }
         } catch (Zend_Locale_Exception $e) {
             $this->_error(self::NOT_FLOAT);
             return false;
         }
     }
     return true;
 }
開發者ID:openbizx,項目名稱:openbizx-cubix,代碼行數:36,代碼來源:Float.php

示例8: testIsFloatFailed

 /**
  * test if isNumberFailed
  * expected boolean
  */
 public function testIsFloatFailed()
 {
     $value = Zend_Locale_Format::isFloat('textwithoutnumber', 'de_AT');
     $this->assertEquals($value, FALSE, "FALSE expected");
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:9,代碼來源:FormatTest.php

示例9: filter

 /**
  * Defined by Zend_Filter_Interface
  *
  * Normalizes the given input
  *
  * @param  string $value Value to normalized
  * @return string|array The normalized value
  */
 public function filter($value)
 {
     if ($this->_options['date_format'] === null && strpos($value, ':') !== false) {
         // Special case, no date format specified, detect time input
         return Zend_Locale_Format::getTime($value, $this->_options);
     } else {
         if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
             // Detect date or time input
             return Zend_Locale_Format::getDate($value, $this->_options);
         } else {
             if ($this->_options['precision'] === 0 && Zend_Locale_Format::isInteger($value, $this->_options)) {
                 // Detect integer
                 return Zend_Locale_Format::getInteger($value, $this->_options);
             } else {
                 if ($this->_options['precision'] === null && Zend_Locale_Format::isFloat($value, $this->_options)) {
                     // Detect float
                     return Zend_Locale_Format::getFloat($value, $this->_options);
                 } else {
                     if (Zend_Locale_Format::isNumber($value, $this->_options)) {
                         // Detect all other numbers
                         return Zend_Locale_Format::getNumber($value, $this->_options);
                     }
                 }
             }
         }
     }
     return $value;
 }
開發者ID:VUW-SIM-FIS,項目名稱:emiemi,代碼行數:36,代碼來源:LocalizedToNormalized.php


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