本文整理汇总了PHP中is_nan函数的典型用法代码示例。如果您正苦于以下问题:PHP is_nan函数的具体用法?PHP is_nan怎么用?PHP is_nan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_nan函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view_non_approve
function view_non_approve()
{
$page = $this->input->get('page');
if ($page == NULL || is_nan($page)) {
$page = 1;
}
// get non-approved dealers
$q = array('dealer_level_id' => 0);
$lim = 15;
$off = $lim * $page - $lim;
$dealers = $this->Dealer->list_dealers($q, $lim, $off, 'obj', 'dealer_datetime DESC , dealer_id DESC');
$rows = $this->Dealer->get_num_rows($q);
$page_amount = 1;
if ($rows % $lim == 0 || $rows % $lim == $lim) {
$page_amount = $rows / $lim;
} else {
$page_amount = $rows / $lim + 1;
}
$data['dealers'] = $dealers;
$data['rows'] = $dealers;
$data['off'] = $off;
$data['pa'] = (int) $page_amount;
$data['page'] = $page;
//load view
$this->load->view('admin_v/waitApprove', $data);
}
示例2: fromDouble
private static function fromDouble($value)
{
if (is_nan($value)) {
return 0;
}
if ($value < -self::TWO_PWR_63_DBL) {
return Long::MIN_VALUE;
}
if ($value >= self::TWO_PWR_63_DBL) {
return Long::MAX_VALUE;
}
$negative = false;
if ($value < 0) {
$negative = true;
$value = -$value;
}
$a2 = 0;
if ($value >= self::TWO_PWR_44_DBL) {
$a2 = (int) ($value / self::TWO_PWR_44_DBL);
$value -= $a2 * self::TWO_PWR_44_DBL;
}
$a1 = 0;
if ($value >= self::TWO_PWR_22_DBL) {
$a1 = (int) ($value / self::TWO_PWR_22_DBL);
$value -= $a1 * self::TWO_PWR_22_DBL;
}
$a0 = (int) $value;
$result = $a2 << 44 | $a1 << 22 | $a0;
if ($negative) {
$result = -$result;
}
return $result;
}
示例3: find
public function find($n)
{
if (isset($n) && !is_nan($n)) {
$n = intval($n);
$query = ' SELECT *
FROM message
ORDER BY rate DESC
LIMIT ' . $n;
} else {
$query = ' SELECT *
FROM message
ORDER BY rate DESC';
}
$res = $this->db->query($query);
if ($res) {
$messages = $res->fetchAll(PDO::FETCH_CLASS, "Message", array($this->db));
if (count($messages) > 0) {
return $messages;
} else {
throw new Exception('No message to show');
}
} else {
throw new Exception('Error 01 : Database error');
}
}
示例4: encode
public static function encode($input)
{
$output = "";
$chr1 = $chr2 = $chr3 = $enc1 = $enc2 = $enc3 = $enc4 = "";
$i = 0;
$input = self::utf8_encode($input);
while ($i < mb_strlen($input)) {
$chr1 = Z_Unicode::charCodeAt($input, $i++);
$chr2 = Z_Unicode::charCodeAt($input, $i++);
$chr3 = Z_Unicode::charCodeAt($input, $i++);
$enc1 = $chr1 >> 2;
$enc2 = ($chr1 & 3) << 4 | $chr2 >> 4;
$enc3 = ($chr2 & 15) << 2 | $chr3 >> 6;
$enc4 = $chr3 & 63;
if (is_nan($chr2)) {
$enc3 = $enc4 = 64;
} else {
if (is_nan($chr3)) {
$enc4 = 64;
}
}
$output = $output . Z_Unicode::charAt(self::$keyStr, $enc1) . Z_Unicode::charAt(self::$keyStr, $enc2) . Z_Unicode::charAt(self::$keyStr, $enc3) . Z_Unicode::charAt(self::$keyStr, $enc4);
}
return $output;
}
示例5: handleSpeed
function handleSpeed($link, $devid, $lat, $long)
{
// Find previous location event for devid
$res = mysql_query("SELECT statusCode,timestamp,latitude,longitude FROM EventData WHERE (deviceID='" . $devid . "' AND statusCode=61472) ORDER BY timestamp DESC LIMIT 1", $link);
// If there is a previous location
if (mysql_num_rows($res) > 0) {
list($statusCode, $lasttime, $lastlat, $lastlong) = mysql_fetch_row($res);
// get time diff
$deltatime = time() - $lasttime;
// calculate heading and speed
$heading = calculateBearing($lastlat, $lastlong, $lat, $long);
if (is_nan($heading)) {
$heading = 0;
}
$speed = calculateSpeed($lastlat, $lastlong, $lat, $long, $deltatime);
if (is_nan($speed)) {
$speed = 0;
}
$retval = array($speed, $heading);
}
if (isset($retval)) {
return $retval;
} else {
return array(0, 0);
}
}
示例6: base64_encode
public function base64_encode($input)
{
$output = "";
$chr1 = $chr2 = $chr3 = $enc1 = $enc2 = $enc3 = $enc4 = null;
$i = 0;
// $input = self::utf8_encode($input);
while ($i < strlen($input)) {
$chr1 = ord($input[$i++]);
$chr2 = ord($input[$i++]);
$chr3 = ord($input[$i++]);
$enc1 = $chr1 >> 2;
$enc2 = ($chr1 & 3) << 4 | $chr2 >> 4;
$enc3 = ($chr2 & 15) << 2 | $chr3 >> 6;
$enc4 = $chr3 & 63;
if (is_nan($chr2)) {
$enc3 = $enc4 = 64;
} else {
if (is_nan($chr3)) {
$enc4 = 64;
}
}
$output .= self::$BinaryMap[$enc1] . self::$BinaryMap[$enc2] . self::$BinaryMap[$enc3] . self::$BinaryMap[$enc4];
}
return $output;
}
示例7: toInteger
/**
* 与えられた値を整数型に変換して返します。
* @link http://www.hcn.zaq.ne.jp/___/WEB/WebIDL-ja.html#es-integers Web IDL (第2版 — 日本語訳)
* @param boolean|integer|float|string|resource|\GMP|\SplInt $value
* @param string $type byte、octet、short、unsigned short、long、unsigned long、long long、unsigned long long
* @param integer|float $min 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
* @param integer|float $max 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
* @param integer $bits
* @param booelan $signed
* @param string $extendedAttribute 拡張属性。[EnforceRange] か [Clamp] のいずれか。
* @return integer|float 整数型の範囲を超える場合は浮動小数点数。
* @throws \InvalidArgumentException 配列、NULL が与えられた場合。または、GMP、SplInt 以外のオブジェクトが与えられた場合。
* @throws \DomainException $extendedAttribute が [EnforceRange]、かつ与えられたの値が $min 〜 $max に収まらなかった場合。
*/
private static function toInteger($value, $type, $min, $max, $bits, $signed, $extendedAttribute = null)
{
/** @var string 要求される型。 */
$expectedType = sprintf('%s (an integer in the range of %s to %s)', $type, is_float($min) ? number_format($min, 0, '', '') : $min, is_float($max) ? number_format($max, 0, '', '') : $max);
if (!self::isIntegerCastable($value)) {
throw new \InvalidArgumentException(ErrorMessageCreator::create($value, $expectedType));
}
if ($value instanceof \GMP || is_resource($value) && get_resource_type($value) === 'GMP integer') {
// GMP数であれば、あらかじめ文字列に変換しておく
$value = gmp_strval($value);
}
/** @var integer|float 与えられた値の数値表現。整数型の範囲を超える場合は浮動小数点数。整数値となる場合、小数部があれば0方向へ丸められる。 */
$number = is_float($value) || (double) $value < self::$phpIntMin || (double) $value > PHP_INT_MAX ? (double) $value : (int) $value;
if ($extendedAttribute === '[EnforceRange]') {
/** @var integer|float 与えられた値の整数表現。整数型の範囲を超える場合は浮動小数点数。 */
$integer = self::roundTowardZero($number);
if (!is_finite($number) || $integer < $min || $integer > $max) {
throw new \DomainException(ErrorMessageCreator::create($value, $expectedType));
}
} elseif (!is_nan($number) && $extendedAttribute === '[Clamp]') {
$number = min(max($number, $min), $max);
$integer = is_float($number) ? round($number, 0, PHP_ROUND_HALF_EVEN) : $number;
} elseif (!is_finite($number)) {
$integer = 0;
} else {
$integer = self::modulo(self::roundTowardZero($number), pow(2, $bits));
if ($signed && $integer >= pow(2, $bits - 1)) {
$integer -= pow(2, $bits);
}
}
return is_float($integer) && $integer >= self::$phpIntMin && $integer <= PHP_INT_MAX ? (int) $integer : $integer;
}
示例8: view_payments
function view_payments()
{
$status = $this->input->get('st');
$page = $this->input->get('page');
if ($page == NULL || $page == '' || is_nan($page)) {
$page = 1;
}
$p_arr = array();
//ftilter
if ($status != NULL && is_numeric($status)) {
$p_arr['order_order_status_id'] = $status;
} else {
$status = "";
}
$off = $this->lim * $page - $this->lim;
$rows = $this->Payment->get_num_rows($p_arr);
if ($rows % $this->lim == 0 || $rows % $this->lim == $this->lim) {
$page_amount = $rows / $this->lim;
} else {
$page_amount = $rows / $this->lim + 1;
}
$payments = $this->Payment->list_payments($p_arr, $this->lim, $off, 'obj');
$sts = $this->Order_status->list_order_status();
$data['payments'] = $payments;
$data['sts'] = $sts;
$data['osid'] = $status;
$data['page_amount'] = $page_amount;
$data['page'] = $page;
$data['rows'] = $rows;
$data['off'] = $off;
$this->load->view('admin_v/allPayment', $data);
}
示例9: getTodaysTotal
/**
* Get the total amount of money raised for today
* @param string $timeZoneOffset The timezone to request the total for
* @param string $today The current date in the requested time zone, e.g. '2011-12-16'
* @param int $fudgeFactor How much to adjust the total by
* @return integer
*/
private function getTodaysTotal($timeZoneOffset, $today, $fudgeFactor = 0)
{
global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
// Delete this block once there is timezone support in the populating script
$setTimeZone = date_default_timezone_set('UTC');
$today = date('Y-m-d');
// Get the current date in UTC
$timeZoneOffset = '+00:00';
$key = wfMemcKey('fundraiserdailytotal', $timeZoneOffset, $today, $fudgeFactor);
$cache = $wgMemc->get($key);
if ($cache != false && $cache != -1) {
return $cache;
}
// Use MediaWiki slave database
$dbr = wfGetDB(DB_SLAVE);
$result = $dbr->select('public_reporting_days', 'round( prd_total ) AS total', array('prd_date' => $today), __METHOD__);
$row = $dbr->fetchRow($result);
if ($row['total'] > 0) {
$total = $row['total'];
} else {
$total = 0;
}
// Make sure the fudge factor is a number
if (is_nan($fudgeFactor)) {
$fudgeFactor = 0;
}
// Add the fudge factor to the total
$total += $fudgeFactor;
$wgMemc->set($key, $total, $egFundraiserStatisticsCacheTimeout);
return $total;
}
示例10: validateValue
public function validateValue($value, $field, $model)
{
$value = $this->cast($value, $field, $model);
$def = $model->fields[$field];
if (is_null($value)) {
$required = $model->checkFieldOptionCondition($field, 'required', false);
if (!$required || !$model->exists() && $model->primaryKey === $field) {
return true;
}
$model->setError($field, 'error-required');
return false;
} else {
if (is_nan($value)) {
$model->setError($field, 'error-numeric');
return false;
}
if (isset($def['gt']) && $value <= $def['gt']) {
$model->setError($field, 'error-numeric-gt');
return false;
}
if (isset($def['gte']) && $value < $def['gt']) {
$model->setError($field, 'error-numeric-gte');
return false;
}
if (isset($def['lt']) && $value >= $def['gt']) {
$model->setError($field, 'error-numeric-lt');
return false;
}
if (isset($def['lte']) && $value > $def['gt']) {
$model->setError($field, 'error-numeric-lte');
return false;
}
}
return parent::validateValue($value, $field, $model);
}
示例11: dumpScalar
protected function dumpScalar($a)
{
switch (true) {
case null === $a:
$this->line .= 'null';
break;
case true === $a:
$this->line .= 'true';
break;
case false === $a:
$this->line .= 'false';
break;
case INF === $a:
$this->line .= '"n`INF"';
break;
case -INF === $a:
$this->line .= '"n`-INF"';
break;
case is_nan($a):
$this->line .= '"n`NAN"';
break;
case $a > 9007199254740992.0 && is_int($a):
$a = '"n`' . $a . '"';
// JavaScript max integer is 2^53
// JavaScript max integer is 2^53
default:
$this->line .= (string) $a;
break;
}
}
示例12: getClosestStations
/**
* Returns a list of all stations according to the lang variable and what the API returns. Normally it will have these variables:
* array[i] -> name
-> locationX
-> locationY
-> standardname
*/
private function getClosestStations($y, $x, $system)
{
include "config.php";
//check if the stationslist hasn't been loaded yet and load the systems
if (!isset($this->{$system})) {
try {
$args = array("system" => $system, "lang" => "NL");
$this->{$system} = APICall::execute("stations", $args);
} catch (Exception $e) {
throw $e;
}
}
$output = array();
$stations = $this->{$system};
//Loop and check if distance is smaller then the vicinity, you only want to get stations nearby
foreach ($stations["station"] as $station) {
$dist = $this->distance($x, $station["locationX"], $y, $station["locationY"]);
if (!is_nan($dist) && $dist < $vicinity) {
$station["distance"] = floor($dist * 1000);
//in meters
$output[sizeof($output)] = $station;
}
}
$output = $this->removeDuplicates($output);
return $output;
}
示例13: brix_to_gravity
function brix_to_gravity()
{
if (is_nan($this->brix)) {
exit;
}
$this->output['b_to_g'] = $this->brix / (258.6 - $this->brix / 258.2 * 227.1) + 1;
}
示例14: parse
/**
* Parses the request.
*
* @return void
*/
public function parse()
{
$filterNode = null;
$limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
if (is_nan($limit)) {
$limit = null;
}
$filter = $this->xpath->query('/card:addressbook-query/card:filter');
if ($filter->length !== 1) {
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
}
$filter = $filter->item(0);
$test = $this->xpath->evaluate('string(@test)', $filter);
if (!$test) {
$test = self::TEST_ANYOF;
}
if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"');
}
$propFilters = array();
$propFilterNodes = $this->xpath->query('card:prop-filter', $filter);
for ($ii = 0; $ii < $propFilterNodes->length; $ii++) {
$propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii));
}
$this->filters = $propFilters;
$this->limit = $limit;
$this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
$this->test = $test;
}
示例15: validateData
function validateData($data, $type)
{
//text check
if ($type == 'abc') {
if ($data == "") {
die("Invalid type");
}
if ($data == " ") {
die("Invalid type");
}
if ($data == " ") {
die("Invalid type");
}
// everything is ok.
//number check
} else {
if ($type == 123) {
if ($data == '') {
die("Invalid type");
}
if (is_nan($data)) {
die("Invalid type");
}
}
}
}