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


PHP CPropertyValue::ensureFloat方法代碼示例

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


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

示例1: testEnsureFloat

 public function testEnsureFloat()
 {
     $entries = array(array(123, 123.0), array(1.23, 1.23), array(null, 0.0), array('', 0.0), array('abc', 0.0), array('123', 123.0), array('1.23', 1.23), array(' 1.23', 1.23), array(' 1.23abc', 1.23), array('abc1.23abc', 0.0), array(true, 1.0), array(false, 0.0), array(array(), 0.0), array(array(0), 1.0));
     foreach ($entries as $index => $entry) {
         $this->assertTrue(CPropertyValue::ensureFloat($entry[0]) === $entry[1], "Comparison {$index}: {$this->varToString($entry[0])}=={$this->varToString($entry[1])}");
     }
 }
開發者ID:super-d2,項目名稱:codeigniter_demo,代碼行數:7,代碼來源:CPropertyValueTest.php

示例2: init

 public function init()
 {
     $this->maxBlockTime = $this->getTimeInterval($this->maxBlockTime);
     $this->alertRepeatInterval = $this->getTimeInterval($this->alertRepeatInterval);
     $this->gatewayMinCredit = CPropertyValue::ensureFloat($this->gatewayMinCredit);
     $gateways = array();
     foreach ($this->gateways as $gateway) {
         $gateways[] = Yii::createComponent($gateway);
     }
     $this->gateways = $gateways;
 }
開發者ID:fduch2k,項目名稱:yii-sms-manager,代碼行數:11,代碼來源:TSSmsManager.php

示例3: convertType

 public function convertType($value)
 {
     $value = trim($value);
     if (ctype_digit($value)) {
         return CPropertyValue::ensureInteger($value);
     }
     if (is_numeric($value)) {
         return CPropertyValue::ensureFloat($value);
     }
     if (strcasecmp($value, 'null') == 0) {
         return null;
     } else {
         if (strcasecmp($value, 'true') == 0 || strcasecmp($value, 'false') == 0) {
             return CPropertyValue::ensureBoolean($value);
         } else {
             if (preg_match('/^\\(.+\\)|\\(\\)$/', $value)) {
                 return CPropertyValue::ensureArray($value);
             }
         }
     }
     return $value;
 }
開發者ID:kuzmina-mariya,項目名稱:unizaro-kamin,代碼行數:22,代碼來源:CDefaultValueValidatorForm.php

示例4: setTimeLimit

 public function setTimeLimit($value)
 {
     $this->_timeLimit = CPropertyValue::ensureFloat($value);
 }
開發者ID:Diakonrus,項目名稱:fastweb-yii,代碼行數:4,代碼來源:YiiDebugToolbarPanelSql.php

示例5: getInput

 /**
  * Extract an data from input data
  *
  * @param string $name can be an normal name or 'Class[attribute]' to get input of a model attribute
  *
  * @param mixed $defaultValue it is recommended to specify default value even when you
  * are sure that the input has data you want to extract.
  *
  * @param string $filter 'xss,notag,newline' filters the data is run through before returned
  * do not combine xss with notag as it slow down the performance.
  */
 public function getInput($name, $defaultValue = null, $filter = '')
 {
     if (is_array($parsedName = $this->parseName($name))) {
         $name = $parsedName[0];
         $key = $parsedName[1];
     }
     if (!array_key_exists($name, $this->data)) {
         return $defaultValue;
     } else {
         $value = $this->data[$name];
         if (isset($key) && is_array($value)) {
             $value = $value[$key];
         }
         if (is_null($value)) {
             return $defaultValue;
         }
     }
     //Run filters
     if (is_string($value) || is_array($value)) {
         foreach ($this->filters as $flt) {
             $value = call_user_func(array($this, $flt), $value, $filter);
         }
     }
     if (is_array($value)) {
         return $value;
     }
     $value = trim($value);
     //Convert to expected type
     if (is_null($defaultValue)) {
         return trim($value);
     }
     if (is_string($defaultValue)) {
         return CPropertyValue::ensureString($value);
     }
     if (is_int($defaultValue)) {
         return CPropertyValue::ensureInteger($value);
     }
     if (is_numeric($defaultValue)) {
         return CPropertyValue::ensureFloat($value);
     }
     if (is_array($defaultValue)) {
         if (!is_array($value)) {
             return array($value);
         } else {
             return $value;
         }
     }
     return $value;
 }
開發者ID:hung5s,項目名稱:yap,代碼行數:60,代碼來源:XInputFilter.php

示例6: init

 public function init()
 {
     $this->minCredit = CPropertyValue::ensureFloat($this->minCredit);
 }
開發者ID:fduch2k,項目名稱:yii-sms-manager,代碼行數:4,代碼來源:TSSmsGateway.php


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