本文整理汇总了PHP中doubleval函数的典型用法代码示例。如果您正苦于以下问题:PHP doubleval函数的具体用法?PHP doubleval怎么用?PHP doubleval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doubleval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSumReport
public function getSumReport($dateFrom, $dateTo)
{
$sum = 0;
$res = Yii::app()->db->createCommand("select sum(paid) 'sum' from tbl_orders where order_date between '{$dateFrom}' and '{$dateTo}'")->queryRow();
$sum = doubleval($res['sum']);
return $sum;
}
开发者ID:kevindaus,项目名称:Order-Billing-Inventory-System-Marcials-Furniture,代码行数:7,代码来源:SumReportFetcher.php
示例2: SubjectEdit
public static function SubjectEdit(Ab_Database $db, $d)
{
$proj = bkint($d->project1) . ',' . bkint($d->project2);
$hours = doubleval($d->numhours1) . '/' . doubleval($d->numhours2);
$sql = "\n\t\t\tUPDATE " . $db->prefix . "rb_subject\n\t\t\tSET \n\t\t\t\tnamesubject='" . bkstr($d->namesubject) . "',\n\t\t\t\tformcontrol='" . bkstr($d->formcontrol) . "',\n\t\t\t\tnumcrs=" . bkint($d->numcrs) . ",\n\t\t\t\tsemestr=" . bkint($d->semestr) . ",\n\t\t\t\tnumhours='" . $hours . "',\n\t\t\t\tproject='" . $proj . "'\n\t\t\tWHERE subjectid=" . bkint($d->subjectid) . " AND fieldid=" . bkint($d->id) . "\n\t\t\tLIMIT 1\n\t\t";
$db->query_write($sql);
}
示例3: timer
/**
* Measure time between two events
*
* First call should be to $key = Debug::timer() with no params, or provide your own key that's not already been used
* Second call should pass the key given by the first call to get the time elapsed, i.e. $time = Debug::timer($key).
* Note that you may make multiple calls back to Debug::timer() with the same key and it will continue returning the
* elapsed time since the original call. If you want to reset or remove the timer, call removeTimer or resetTimer.
*
* @param string $key
* Leave blank to start timer.
* Specify existing key (string) to return timer.
* Specify new made up key to start a named timer.
* @param bool $reset If the timer already exists, it will be reset when this is true.
* @return string|int
*
*/
public static function timer($key = '', $reset = false)
{
// returns number of seconds elapsed since first call
if ($reset && $key) {
self::removeTimer($key);
}
if (!$key || !isset(self::$timers[$key])) {
// start new timer
preg_match('/(\\.[0-9]+) ([0-9]+)/', microtime(), $time);
$startTime = doubleval($time[1]) + doubleval($time[2]);
if (!$key) {
$key = $startTime;
while (isset(self::$timers[$key])) {
$key .= ".";
}
}
self::$timers[$key] = $startTime;
$value = $key;
} else {
// return timer
preg_match('/(\\.[0-9]*) ([0-9]*)/', microtime(), $time);
$endTime = doubleval($time[1]) + doubleval($time[2]);
$startTime = self::$timers[$key];
$runTime = number_format($endTime - $startTime, 4);
$value = $runTime;
}
return $value;
}
示例4: filterPrice
function filterPrice($price)
{
$price = str_replace('Rp ', '', $price);
$price = str_replace(',', '', $price);
$num_price = doubleval($price);
return $num_price;
}
示例5: prepocetBodu
/**
* Prepocte bodovou hodnotu zaplavaneho casu
* @param string $year Rok pro vyber zakladnich casu
* @param string $id Identifikator radku
* @param string $id_event Identifikator zavodu
* @param string $id_stroke Identifikator stylu
* @param string $id_swimmer Identifikator plavce
* @param string $time Zaplavany cas
* @return int Vypocteny pocet bodu
*/
private function prepocetBodu($year, $id, $id_event, $id_stroke, $id_swimmer, $time)
{
// Dotaz na delku bazenu (1 - 50m tzn. LCM, 0 - 25m tzn. SCM)
$lcm = $this->database->query('select lcm from sm_event where id = ?', $id_event)->fetchField();
if ($lcm == 0) {
$lcm = 'SCM';
} else {
$lcm = 'LCM';
}
// Dotaz na pohlavi plavce (M - muz, Z - zena)
$sex = $this->database->query('select sex from sm_swimmer where id = ?', $id_swimmer)->fetchField();
if ($sex == 'Z') {
$sex = 'F';
}
// Dotaz na zakladni cas
$b = $this->database->query('select basetime_s from sm_bt ' . 'where year=? and course=? and sex=? and relay=1 and stroke=?', $year, $lcm, $sex, $id_stroke)->fetchField();
// Prevod zaplavaneho casu na sekundy (mm:ss,ss)
$t1 = doubleval(substr($time, 0, 2)) * 60;
// Minuty
$t2 = doubleval(substr(str_replace(',', '.', $time), 3));
// Sekundy
$t = $t1 + $t2;
// Vlastni vypocet bodu
$p = round(1000 * pow($b / $t, 3));
// Zapis prepoctene hodnoty bodu do tabulky
//$this->database->query('UPDATE sm_time_pom SET point=? WHERE id=?', $p, $id);
$this->database->table($this->tableName)->where('id', $id)->update(['point' => $p]);
//$p]);
return $p;
}
示例6: lookUp
/**
*
* @param string $latLong
* @param bool $forceReload
* @return \models\entities\GeocodeCached Description
*
*/
public function lookUp($latLong, $forceReload = false)
{
list($lat, $long) = explode(',', $latLong);
$preciseLat = round(doubleval($lat), self::GEOCODE_PRECISION);
$preciseLong = round(doubleval($long), self::GEOCODE_PRECISION);
if (!$forceReload) {
$lookUpWhere = (new \DbTableWhere())->where('longitude', $preciseLong)->where('latitude', $preciseLat)->setLimitAndOffset(1);
$cachedList = \models\entities\GeocodeCached::manager()->getEntitiesWhere($lookUpWhere);
if (count($cachedList)) {
return $cachedList[0];
}
}
foreach ($this->serviceProviderList as $serviceProvier) {
$lookUpResult = $serviceProvier->lookUp($preciseLong, $preciseLat);
\SystemLogger::debug("Making call with: ", $serviceProvier->getClassBasic());
if ($lookUpResult && ($lookUpResult->getCity() || $lookUpResult->getPostalCode())) {
//var_dump($lookUpResult);exit;
return $this->cacheLookup($lookUpResult, $preciseLong, $preciseLat);
} else {
if ($lastError = $serviceProvier->getLastError(true)) {
\SystemLogger::warn("Error: {$lastError->getMessage()} TYPE: {$lastError->getType()}");
}
if ($lastError && !$lastError->isRateLimit()) {
break;
}
}
}
return null;
}
示例7: index
/**
* Display the specified resource.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
* @internal param \Illuminate\Http\Request $request
* @internal param int $id
*/
public function index(Request $request)
{
// Get lat / lng
$lat = $request->get('lat', false);
$lng = $request->get('lng', false);
if (!$lat || !$lng) {
return response()->json(['message' => 'Both latitude and longitude are required.'], Response::HTTP_BAD_REQUEST);
}
if (!is_numeric($lat) || !is_numeric($lng)) {
return response()->json(['message' => 'Both latitude and longitude must be double values.'], Response::HTTP_BAD_REQUEST);
}
$stationRepository = StationRepository::getInstance();
$station = $stationRepository->getCaqiForLocation(doubleval($lat), doubleval($lng));
if (!empty($station)) {
// Get measurements for components
$componentsRepository = ComponentRepository::getInstance();
$measurementRepository = MeasurementRepository::getInstance();
$components = $componentsRepository->getAll();
$componentMeasurements = [];
/** @var Component $component */
foreach ($components as $component) {
// Get latest measurement!
$measurement = $measurementRepository->getLatestForStationAndComponent($station, $component);
$componentMeasurements[$component->getSepaId()]['measurement'] = $measurement;
$componentMeasurements[$component->getSepaId()]['component'] = $component;
}
$responseData = ['station' => $station, 'components' => $componentMeasurements];
return response()->json($responseData);
}
return response()->json([], Response::HTTP_NO_CONTENT);
}
示例8: __set
function __set($key, $value)
{
if (!isset(static::$fields[$key])) {
throw new exception("CTwiz property field " . $key . " doesn't exist");
}
if (gettype($value) == static::$fields[$key]) {
$this->data[$key] = $value;
return true;
}
switch (static::$fields[$key]) {
case 'boolean':
$this->data[$key] = $value ? true : false;
return true;
case 'string':
$this->data[$key] = "" + $value;
return true;
case 'integer':
$parts = explode("-", $value);
$max = max($parts);
$this->data[$key] = intval($max);
return true;
case 'double':
$parts = explode("-", $value);
$max = max($parts);
$this->data[$key] = doubleval($max);
return true;
}
throw new exception("CTwiz property wrong data type " . gettype($value) . " for " . $key . ". Should be " . static::$fields[$key]);
}
示例9: olc_format_price_order
function olc_format_price_order($price_string, $price_special, $currency, $show_currencies = 1)
{
if (doubleval($price_string) != 0) {
include DIR_FS_INC . 'olc_get_currency_parameters.inc.php';
if ($calculate_currencies == TRUE_STRING_S) {
$price_string = $price_string * CURRENCY_VALUE;
}
// round price
$price_string = olc_precision($price_string, CURRENCY_DECIMAL_PLACES);
if ($price_special == '1') {
$price_string = number_format($price_string, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT);
if ($show_currencies == 1) {
$price_string = CURRENCY_SYMBOL_LEFT . $price_string . CURRENCY_SYMBOL_RIGHT;
}
}
//1,00 -> 1,--
global $is_print_version, $is_pdf;
if ($is_print_version) {
if ($is_pdf) {
$s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT_PDF;
} else {
$s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT;
}
} else {
$s = CURRENCY_DECIMAL_ZEROES_DASHES;
}
$price_string = str_replace(CURRENCY_DECIMAL_ZEROES, $s, $price_string);
} else {
$price_string = EMPTY_STRING;
}
return $price_string;
}
示例10: normalizarvalor
function normalizarvalor($valor, $tipo, $largo = 0, $definido = "")
{
$valor = !get_magic_quotes_gpc() ? addslashes($valor) : $valor;
switch ($tipo) {
case "varchar":
$valor = !empty($valor) ? substr(strtoupper($valor), 0, intval($largo)) : "NULL";
break;
case "int":
$valor = !empty($valor) ? intval($valor) : "NULL";
break;
case "tinyint":
$valor = !empty($valor) ? intval($valor) : "NULL";
break;
case "double":
$valor = $valor != "" ? doubleval($valor) : "NULL";
break;
case "date":
$valor = $valor != "" ? $valor : "NULL";
break;
case "enum":
$valor = !empty($valor) ? $valor : $definido;
break;
}
return strtoupper($valor);
}
示例11: calculate
/**
* Calculate
*
* @return void
*/
public function calculate()
{
$zones = $this->getZonesList();
$memebrship = $this->getMembership();
foreach ($this->getTaxes() as $tax) {
$previousItems = array();
$previousClasses = array();
$cost = 0;
$ratesExists = false;
foreach ($tax->getFilteredRates($zones, $memebrship) as $rate) {
$ratesExists = true;
$productClass = $rate->getProductClass() ?: null;
if (!in_array($productClass, $previousClasses)) {
$items = $this->getTaxableItems($productClass, $previousItems);
if ($items) {
foreach ($items as $item) {
$previousItems[] = $item->getProduct()->getProductId();
}
$cost += $rate->calculate($items);
}
$previousClasses[] = $productClass;
}
}
if ($cost) {
$this->addOrderSurcharge($this->code . '.' . $tax->getId(), doubleval($cost), false, $ratesExists);
}
}
}
示例12: verify_payment
/**
* Perform verification of the payment, this is called from the payment gateway
*
* @return bool Whether the payment is valid
*/
function verify_payment()
{
$this->registry->input->clean_array_gpc('p', array('pay_to_email' => TYPE_STR, 'merchant_id' => TYPE_STR, 'transaction_id' => TYPE_STR, 'mb_transaction_id' => TYPE_UINT, 'status' => TYPE_STR, 'md5sig' => TYPE_STR, 'amount' => TYPE_STR, 'currency' => TYPE_STR, 'mb_amount' => TYPE_STR, 'mb_currency' => TYPE_STR));
if (!$this->test()) {
$this->error = 'Payment processor not configured';
return false;
}
$this->transaction_id = $this->registry->GPC['mb_transaction_id'];
$check_hash = strtoupper(md5($this->registry->GPC['merchant_id'] . $this->registry->GPC['transaction_id'] . strtoupper(md5(strtolower($this->settings['mbsecret']))) . $this->registry->GPC['mb_amount'] . $this->registry->GPC['mb_currency'] . $this->registry->GPC['status']));
if ($check_hash == $this->registry->GPC['md5sig'] and strtolower($this->registry->GPC['pay_to_email']) == strtolower($this->settings['mbemail'])) {
if (intval($this->registry->GPC['status']) == 2) {
$this->paymentinfo = $this->registry->db->query_first("\n\t\t\t\t\tSELECT paymentinfo.*, user.username\n\t\t\t\t\tFROM " . TABLE_PREFIX . "paymentinfo AS paymentinfo\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user USING (userid)\n\t\t\t\t\tWHERE hash = '" . $this->registry->db->escape_string($this->registry->GPC['transaction_id']) . "'\n\t\t\t\t");
// lets check the values
if (!empty($this->paymentinfo)) {
$sub = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "subscription WHERE subscriptionid = " . $this->paymentinfo['subscriptionid']);
$cost = unserialize($sub['cost']);
$this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
$this->paymentinfo['amount'] = floatval($this->registry->GPC['amount']);
if (doubleval($this->registry->GPC['amount']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
$this->type = 1;
return true;
}
}
}
}
return false;
}
示例13: validator
/**
* 验证字段是否符合注解数据参数约定条件,如果不能满足条件,返回错误结束该请求。
*
* @param string $key 传入的域的值
* @param int $value
* @param array $params 基于类模板读取的注解数组。
*/
public function validator($key, $value, $params)
{
//是否必须检测
if (isset($params[DoubleValidator::$_REQUIRED]) && $params[DoubleValidator::$_REQUIRED] == true) {
if (!is_numeric($value)) {
ResponseApi::sendErrorAndEnd($key . "=" . $value . "是必填项)", Message::$_ERROR_FORMAT);
}
}
if ($value != null) {
//类型检查
if (!is_numeric($value)) {
ResponseApi::sendErrorAndEnd($key . "=" . $value . "必须是double型)", Message::$_ERROR_FORMAT);
}
$dvalue = doubleval($value);
if (isset($params[DoubleValidator::$_MIN])) {
$min_d = $params[DoubleValidator::$_MIN];
if (isset($min_d)) {
if ($min_d && $dvalue < $min_d) {
ResponseApi::sendErrorAndEnd($key . "=" . $value . "是最小值是" . $min_d . ")", Message::$_ERROR_FORMAT);
}
}
}
if (isset($params[DoubleValidator::$_MAX])) {
$max_d = $params[DoubleValidator::$_MAX];
if (isset($max_d)) {
if ($max_d && $dvalue > $max_d) {
ResponseApi::sendErrorAndEnd($key . "=" . $value . "是最大值是" . $max_d . ")", Message::$_ERROR_FORMAT);
}
}
}
}
}
示例14: store
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*
*/
public function store(Request $request)
{
// Read subscriber details
$uuid = $request->json('uuid');
$latitude = $request->json('latitude');
$longitude = $request->json('longitude');
// Validate latitude/longitude
if (!is_numeric($latitude)) {
return response()->json(['message' => "Latitude must be a number."], Response::HTTP_BAD_REQUEST);
}
if (!is_numeric($longitude)) {
return response()->json(['message' => "Longitude must be a number."], Response::HTTP_BAD_REQUEST);
}
// Check if user is already subscribed
$repository = SubscriberRepository::getInstance();
$subscriber = $repository->getByUuid($uuid);
if (!empty($subscriber)) {
return response()->json(['message' => "Already subscribed."], Response::HTTP_BAD_REQUEST);
}
$subscriber = new Subscriber();
$subscriber->setUuid($uuid);
$subscriber->setLatitude(doubleval($latitude));
$subscriber->setLongitude(doubleval($longitude));
try {
$subscriber->save();
} catch (QueryException $exception) {
return response()->json(['message' => "Oops, something went wrong."], Response::HTTP_INTERNAL_SERVER_ERROR);
}
return response()->json([], Response::HTTP_CREATED);
}
示例15: loadDataSources
public function loadDataSources()
{
$chartInitialData = array();
$sipAccountNames = array();
$chartSeriesData = array();
$criteria = new CDbCriteria();
$criteria->order = "vici_user ASC";
$allRemoteModels = RemoteDataCache::model()->findAll($criteria);
foreach ($allRemoteModels as $key => $currentRemoteData) {
$tempColorContainer = "red";
//collect sip accounts
$sipAccountNames[$key] = $currentRemoteData->sub_user;
//register chart data array
$chartInitialData = array("name" => $currentRemoteData->sub_user, "data" => $currentRemoteData->exact_balance);
if (doubleval($currentRemoteData->exact_balance) >= 5) {
$tempColorContainer = "#7CB5EC";
} else {
if ($currentRemoteData->exact_balance > 3) {
$tempColorContainer = "orange";
}
}
//register series data
$chartSeriesData[$key] = array("y" => doubleval($currentRemoteData->exact_balance), "color" => $tempColorContainer);
}
return array('iniChartData' => $chartInitialData, 'sipAccountStr' => $sipAccountNames, 'chartSeriesData' => $chartSeriesData);
}