当前位置: 首页>>代码示例>>PHP>>正文


PHP floatval函数代码示例

本文整理汇总了PHP中floatval函数的典型用法代码示例。如果您正苦于以下问题:PHP floatval函数的具体用法?PHP floatval怎么用?PHP floatval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了floatval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addRegistro

 function addRegistro($data)
 {
     $querys = new Querys();
     // Data cadastro atual
     $data[$this->tabela_data_entrada] = date('Y-m-d H:i:s');
     // Retorna todos os campos da tabela
     $result = $this->getCampos();
     // Monta sql
     $sql = "INSERT INTO " . $this->tabela . " SET ";
     foreach ($result['nome'] as $key => $campo) {
         if (isset($data[$result['nome'][$key]]) && !empty($data[$result['nome'][$key]])) {
             if ($result['tipo'][$key] == 'int') {
                 $sql .= $result['nome'][$key] . " = '" . (int) $data[$result['nome'][$key]] . "', ";
             } else {
                 if ($result['tipo'][$key] == 'real') {
                     $sql .= $result['nome'][$key] . " = " . floatval($data[$result['nome'][$key]]) . ", ";
                 } else {
                     $sql .= $result['nome'][$key] . " = '" . $querys->escape($data[$result['nome'][$key]]) . "', ";
                 }
             }
         }
     }
     $sql = substr(trim($sql), 0, -1);
     $result = $querys->query($sql);
     return $result;
 }
开发者ID:ExtraProgrammers,项目名称:PrivateGSIASorteios,代码行数:26,代码来源:Participantes.php

示例2: getData

 /**
  * @see OptionType::getData()
  */
 public function getData($optionData, $newValue)
 {
     $newValue = str_replace(' ', '', $newValue);
     $newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
     $newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue);
     return floatval($newValue);
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:10,代码来源:OptionTypeFloat.class.php

示例3: formatPriceToUS

 /**
  * Returns the first found number from an string
  * Parsing depends on given locale (grouping and decimal)
  *
  * Examples for input:
  * '  2345.4356,1234' = 23455456.1234
  * '+23,3452.123' = 233452.123
  * ' 12343 ' = 12343
  * '-9456km' = -9456
  * '0' = 0
  * '2 054,10' = 2054.1
  * '2'054.52' = 2054.52
  * '2,46 GB' = 2.46
  *
  * @param string|int $value
  * @return float
  */
 public static function formatPriceToUS($value)
 {
     if (is_null($value)) {
         return null;
     }
     if (!is_string($value)) {
         return floatval($value);
     }
     //trim space and apos
     $value = str_replace('\'', '', $value);
     $value = str_replace(' ', '', $value);
     $separatorComa = strpos($value, ',');
     $separatorDot = strpos($value, '.');
     if ($separatorComa !== false && $separatorDot !== false) {
         if ($separatorComa > $separatorDot) {
             $value = str_replace('.', '', $value);
             $value = str_replace(',', '.', $value);
         } else {
             $value = str_replace(',', '', $value);
         }
     } elseif ($separatorComa !== false) {
         $value = str_replace(',', '.', $value);
     }
     return floatval($value);
 }
开发者ID:adrianomelo5,项目名称:magento,代码行数:42,代码来源:Math.php

示例4: upload

 public function upload()
 {
     /** import upload library **/
     _wpl_import('assets.packages.ajax_uploader.UploadHandler');
     $kind = wpl_request::getVar('kind', 0);
     $params = array();
     $params['accept_ext'] = wpl_flex::get_field_options(301);
     $extentions = explode(',', $params['accept_ext']['ext_file']);
     $ext_str = '';
     foreach ($extentions as $extention) {
         $ext_str .= $extention . '|';
     }
     // remove last |
     $ext_str = substr($ext_str, 0, -1);
     $ext_str = rtrim($ext_str, ';');
     $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null);
     $upload_handler = new UploadHandler($custom_op);
     $response = json_decode($upload_handler->json_response);
     if (isset($response->files[0]->error)) {
         return;
     }
     $attachment_categories = wpl_items::get_item_categories('attachment', $kind);
     // get item category with first index
     $item_cat = reset($attachment_categories)->category_name;
     $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0;
     $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index);
     wpl_items::save($item);
 }
开发者ID:gvh1993,项目名称:project-vvvh,代码行数:28,代码来源:wpl_attachments.php

示例5: indexOp

 public function indexOp()
 {
     //查询会员及其附属信息
     $result = parent::pointshopMInfo(true);
     $member_info = $result['member_info'];
     unset($result);
     $model_member = Model('member');
     //获得会员升级进度
     $membergrade_arr = $model_member->getMemberGradeArr(true, $member_info['member_exppoints'], $member_info['level']);
     Tpl::output('membergrade_arr', $membergrade_arr);
     //处理经验值计算说明文字
     $exppoints_rule = C("exppoints_rule") ? unserialize(C("exppoints_rule")) : array();
     $ruleexplain_arr = array();
     $exppoints_rule['exp_orderrate'] = floatval($exppoints_rule['exp_orderrate']);
     if ($exppoints_rule['exp_orderrate'] > 0) {
         $ruleexplain_arr['exp_order'] = "经验值以有效购物金额作为计算标准,有效购物金额{$exppoints_rule['exp_orderrate']}元=1经验值;";
         $exp_ordermax = intval($exppoints_rule['exp_ordermax']);
         if ($exp_ordermax > 0) {
             $ruleexplain_arr['exp_order'] .= "单个订单最多获得{$exppoints_rule['exp_ordermax']}经验值;";
         }
     }
     $exppoints_rule['exp_login'] = intval($exppoints_rule['exp_login']);
     if ($exppoints_rule['exp_login'] > 0) {
         $ruleexplain_arr['exp_login'] = "会员每天第一次登录获得{$exppoints_rule['exp_login']}经验值;";
     }
     $exppoints_rule['exp_comments'] = intval($exppoints_rule['exp_comments']);
     if ($exppoints_rule['exp_comments'] > 0) {
         $ruleexplain_arr['exp_comments'] = "进行一次订单商品评价将获得{$exppoints_rule['exp_comments']}经验值;";
     }
     Tpl::output('ruleexplain_arr', $ruleexplain_arr);
     //分类导航
     $nav_link = array(0 => array('title' => L('homepage'), 'link' => SHOP_SITE_URL), 1 => array('title' => L('nc_pointprod'), 'link' => urlShop('pointshop', 'index')), 2 => array('title' => '我的成长进度'));
     Tpl::output('nav_link_list', $nav_link);
     Tpl::showpage('pointgrade');
 }
开发者ID:mengtaolin,项目名称:shopping,代码行数:35,代码来源:pointgrade.php

示例6: perform

 function perform(&$page, $actionName)
 {
     // like in Action_Next
     $page->isFormBuilt() or $page->buildForm();
     $page->handle('display');
     $strings = $page->controller->exportValue('page4', 'strings');
     $bar = $page->controller->createProgressBar();
     do {
         $percent = $bar->getPercentComplete();
         if ($bar->isStringPainted()) {
             if (substr($strings, -1) == ";") {
                 $str = explode(";", $strings);
             } else {
                 $str = explode(";", $strings . ";");
             }
             for ($i = 0; $i < count($str) - 1; $i++) {
                 list($p, $s) = explode(",", $str[$i]);
                 if ($percent == floatval($p) / 100) {
                     $bar->setString(trim($s));
                 }
             }
         }
         $bar->display();
         if ($percent == 1) {
             break;
             // the progress bar has reached 100%
         }
         $bar->sleep();
         $bar->incValue();
     } while (1);
 }
开发者ID:Ogwang,项目名称:sainp,代码行数:31,代码来源:preview.php

示例7: smarty_modifier_currency

/**
 * Formats a given decimal value to a local aware currency value
 *
 *
 * @link http://framework.zend.com/manual/de/zend.currency.options.html
 * @param float  $value Value can have a coma as a decimal separator
 * @param array  $config
 * @param string $position where the currency symbol should be displayed
 * @return float|string
 */
function smarty_modifier_currency($value, $config = null, $position = null)
{
    if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) {
        return $value;
    }
    if (!empty($config) && is_string($config)) {
        $config = strtoupper($config);
        if (defined('Zend_Currency::' . $config)) {
            $config = array('display' => constant('Zend_Currency::' . $config));
        } else {
            $config = array();
        }
    } else {
        $config = array();
    }
    if (!empty($position) && is_string($position)) {
        $position = strtoupper($position);
        if (defined('Zend_Currency::' . $position)) {
            $config['position'] = constant('Zend_Currency::' . $position);
        }
    }
    $currency = Enlight_Application::Instance()->Currency();
    $value = floatval(str_replace(',', '.', $value));
    $value = $currency->toCurrency($value, $config);
    if (function_exists('mb_convert_encoding')) {
        $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
    }
    $value = htmlentities($value, ENT_COMPAT, 'UTF-8', false);
    return $value;
}
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:40,代码来源:modifier.currency.php

示例8: postToLaybuy

 public function postToLaybuy()
 {
     $this->load->model('extension/payment/laybuy');
     $this->model_extension_payment_laybuy->log('Posting to Laybuy');
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $this->load->model('checkout/order');
         $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
         if ($order_info) {
             $this->model_extension_payment_laybuy->log('Order ID: ' . $order_info['order_id']);
             $data = array();
             $data['VERSION'] = '0.2';
             $data['MEMBER'] = $this->config->get('laybuys_membership_id');
             $data['RETURNURL'] = $this->url->link('extension/payment/laybuy/callback', '', true);
             $data['CANCELURL'] = $this->url->link('extension/payment/laybuy/cancel', '', true);
             $data['AMOUNT'] = round(floatval($order_info['total']), 2, PHP_ROUND_HALF_DOWN);
             $data['CURRENCY'] = $order_info['currency_code'];
             $data['INIT'] = (int) $this->request->post['INIT'];
             $data['MONTHS'] = (int) $this->request->post['MONTHS'];
             $data['MIND'] = (int) $this->config->get('laybuy_min_deposit') ? (int) $this->config->get('laybuy_min_deposit') : 20;
             $data['MAXD'] = (int) $this->config->get('laybuy_max_deposit') ? (int) $this->config->get('laybuy_max_deposit') : 50;
             $data['CUSTOM'] = $order_info['order_id'] . ':' . md5($this->config->get('laybuy_token'));
             $data['EMAIL'] = $order_info['email'];
             $data_string = '';
             foreach ($data as $param => $value) {
                 $data_string .= $param . '=' . $value . '&';
             }
             $data_string = rtrim($data_string, '&');
             $this->model_extension_payment_laybuy->log('Data String: ' . $data_string);
             $this->model_extension_payment_laybuy->log('Gateway URL: ' . $this->config->get('laybuy_gateway_url'));
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $this->config->get('laybuy_gateway_url'));
             curl_setopt($ch, CURLOPT_POST, true);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_HEADER, false);
             curl_setopt($ch, CURLOPT_TIMEOUT, 30);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             $result = curl_exec($ch);
             if (curl_errno($ch)) {
                 $this->model_extension_payment_laybuy->log('cURL error: ' . curl_errno($ch));
             }
             curl_close($ch);
             $result = json_decode($result, true);
             $this->model_extension_payment_laybuy->log('Response: ' . print_r($result, true));
             if (isset($result['ACK']) && isset($result['TOKEN']) && $result['ACK'] == 'SUCCESS') {
                 $this->model_extension_payment_laybuy->log('Success response. Redirecting to PayPal.');
                 $this->response->redirect($this->config->get('laybuy_gateway_url') . '?TOKEN=' . $result['TOKEN']);
             } else {
                 $this->model_extension_payment_laybuy->log('Failure response. Redirecting to checkout/failure.');
                 $this->response->redirect($this->url->link('checkout/failure', '', true));
             }
         } else {
             $this->model_extension_payment_laybuy->log('No matching order. Redirecting to checkout/failure.');
             $this->response->redirect($this->url->link('checkout/failure', '', true));
         }
     } else {
         $this->model_extension_payment_laybuy->log('No $_POST data. Redirecting to checkout/failure.');
         $this->response->redirect($this->url->link('checkout/failure', '', true));
     }
 }
开发者ID:brunoxu,项目名称:mycncart,代码行数:60,代码来源:laybuy.php

示例9: realFilesize

function realFilesize($filename)
{
    $fp = fopen($filename, 'r');
    $return = false;
    if (is_resource($fp)) {
        if (PHP_INT_SIZE < 8) {
            if (0 === fseek($fp, 0, SEEK_END)) {
                $return = 0.0;
                $step = 0x7fffffff;
                while ($step > 0) {
                    if (0 === fseek($fp, -$step, SEEK_CUR)) {
                        $return += floatval($step);
                    } else {
                        $step >>= 1;
                    }
                }
            }
        } else {
            if (0 === fseek($fp, 0, SEEK_END)) {
                $return = ftell($fp);
            }
        }
    }
    return $return;
}
开发者ID:GvarimAZA,项目名称:website,代码行数:25,代码来源:functions.php

示例10: __construct

 /**
  * @brief Checks whether our assumptions hold on the PHP platform we are on.
  *
  * @throws \RunTimeException if our assumptions do not hold on the current
  *                           PHP platform.
  */
 public function __construct()
 {
     $pow_2_53 = floatval(self::POW_2_53_MINUS_1) + 1.0;
     if ($this->formatUnsignedInteger($pow_2_53) !== self::POW_2_53) {
         throw new \RunTimeException('This class assumes floats to be double precision or "better".');
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:LargeFileHelper.php

示例11: index

 public function index()
 {
     $modules = $this->read_modules();
     $db_modules = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "collocation");
     foreach ($modules as $k => $v) {
         foreach ($db_modules as $kk => $vv) {
             if ($v['class_name'] == $vv['class_name']) {
                 //已安装
                 $modules[$k]['name'] = $vv['name'];
                 $modules[$k]['id'] = $vv['id'];
                 $modules[$k]['total_amount'] = $vv['total_amount'];
                 $modules[$k]['installed'] = $vv['is_effect'];
                 $modules[$k]['is_effect'] = $vv['is_effect'];
                 $modules[$k]['sort'] = $vv['sort'];
                 break;
             }
         }
         if ($modules[$k]['installed'] != 1) {
             $modules[$k]['installed'] = 0;
         }
         $modules[$k]['is_effect'] = intval($modules[$k]['is_effect']);
         $modules[$k]['sort'] = intval($modules[$k]['sort']);
         $modules[$k]['total_amount'] = floatval($modules[$k]['total_amount']);
         $modules[$k]['reg_url'] = $v['reg_url'] ? $v['reg_url'] : '';
     }
     $this->assign("collocation_list", $modules);
     $this->display();
 }
开发者ID:eliu03,项目名称:fanweP2P,代码行数:28,代码来源:CollocationAction.class.php

示例12: getNonCancelledPaymentOrdersByCurrency

 public function getNonCancelledPaymentOrdersByCurrency($date, $currencyId)
 {
     $sql = "SELECT SUM(amount) AS amount FROM `%s` WHERE `cancelled` = 0 AND `paid` = 1 AND currency_id=:id AND `date`<=DATE_ADD('%s' ,INTERVAL 1 DAY)";
     $sqlQuery = sprintf($sql, $this->getTableName(), $date);
     $qty = $this->fetchField($sqlQuery, 'amount', array("id" => $currencyId));
     return isset($qty) ? floatval($qty) : 0;
 }
开发者ID:pars5555,项目名称:crm,代码行数:7,代码来源:PaymentTransactionMapper.class.php

示例13: to_money

 public function to_money($number, $do_encode = false)
 {
     if (!is_numeric($number)) {
         $number = $this->to_number($number);
     }
     if ($number === false) {
         return '';
     }
     $negative = '';
     if (strpos(strval($number), '-') !== false) {
         $negative = '-';
         $number = floatval(substr($number, 1));
     }
     $money = number_format($number, $this->currency['decimals'], $this->currency['decimal_separator'], $this->currency['thousand_separator']);
     if ($money == '0.00') {
         $negative = '';
     }
     $symbol_left = !empty($this->currency['symbol_left']) ? $this->currency['symbol_left'] . $this->currency['symbol_padding'] : '';
     $symbol_right = !empty($this->currency['symbol_right']) ? $this->currency['symbol_padding'] . $this->currency['symbol_right'] : '';
     if ($do_encode) {
         $symbol_left = html_entity_decode($symbol_left);
         $symbol_right = html_entity_decode($symbol_right);
     }
     return $negative . $symbol_left . $money . $symbol_right;
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:25,代码来源:currency.php

示例14: getPrice

 function getPrice()
 {
     //echo '<pre>';print_r($this->price_filter);exit;
     $str = $this->getReplaceResult($this->price_filter, $this->html_content, 'price');
     if (empty($str)) {
         for ($i = 0, $len = count($this->price_filter['discount']); $i < $len; $i++) {
             $str = $this->getReplaceResult($this->price_filter['discount'][$i], $this->html_content);
             if (strlen($str) > 0) {
                 break;
             }
         }
         if (empty($str)) {
             $this->error_msg['price_error'] = 'error: empty product price and discount price';
         }
     }
     if (!isset($this->error_msg['price_error'])) {
         $str = preg_replace("/^\\D+|\\D+\$/", '', $str);
         $str = floatval($str);
         $this->reduce_price_num = floatval($this->reduce_price_num);
         if ($str - $this->reduce_price_num > 0) {
             $str = $str - $this->reduce_price_num;
         }
         $this->product_info['price'] = $str;
     }
 }
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:25,代码来源:add_product_model.php

示例15: index

 /**
  * index method
  *
  * @return void
  * @access public
  */
 public function index($type = null, $lat = null, $long = null, $opt1 = null, $opt2 = null)
 {
     $params = array('limit' => 35, 'page' => 1);
     if (!empty($type) && !empty($lat) && !empty($long)) {
         $lat = floatval($lat);
         $long = floatval($long);
         $opt1 = floatval($opt1);
         $opt2 = floatval($opt2);
         switch ($type) {
             case 'near':
                 if (!empty($opt1)) {
                     $cond = array('loc' => array('$near' => array($lat, $long), '$maxDistance' => $opt1));
                 } else {
                     $cond = array('loc' => array('$near' => array($lat, $long)));
                 }
                 break;
             case 'box':
                 $lowerLeft = array($lat, $long);
                 $upperRight = array($opt1, $opt2);
                 $cond = array('loc' => array('$within' => array('$box' => array($lowerLeft, $upperRight))));
                 break;
             case 'circle':
                 $center = array($lat, $long);
                 $radius = $opt1;
                 $cond = array('loc' => array('$within' => array('$center' => array($center, $radius))));
                 break;
         }
         $params['conditions'] = $cond;
     } else {
         $params['order'] = array('_id' => -1);
     }
     $results = $this->Geo->find('all', $params);
     $this->set(compact('results'));
 }
开发者ID:ThemisB,项目名称:mongoDB-Datasource,代码行数:40,代码来源:geos_controller.php


注:本文中的floatval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。