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


PHP Math::isFinite方法代码示例

本文整理汇总了PHP中Math::isFinite方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::isFinite方法的具体用法?PHP Math::isFinite怎么用?PHP Math::isFinite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Math的用法示例。


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

示例1: serialize

 public function serialize($v)
 {
     $_g = Type::typeof($v);
     switch ($_g->index) {
         case 0:
             $this->buf->add("n");
             break;
         case 1:
             $v1 = $v;
             if ($v1 === 0) {
                 $this->buf->add("z");
                 return;
             }
             $this->buf->add("i");
             $this->buf->add($v1);
             break;
         case 2:
             $v2 = $v;
             if (Math::isNaN($v2)) {
                 $this->buf->add("k");
             } else {
                 if (!Math::isFinite($v2)) {
                     $this->buf->add($v2 < 0 ? "m" : "p");
                 } else {
                     $this->buf->add("d");
                     $this->buf->add($v2);
                 }
             }
             break;
         case 3:
             $this->buf->add($v ? "t" : "f");
             break;
         case 6:
             $c = _hx_deref($_g)->params[0];
             if (is_object($_t = $c) && !$_t instanceof Enum ? $_t === _hx_qtype("String") : $_t == _hx_qtype("String")) {
                 $this->serializeString($v);
                 return;
             }
             if ($this->useCache && $this->serializeRef($v)) {
                 return;
             }
             switch ($c) {
                 case _hx_qtype("Array"):
                     $ucount = 0;
                     $this->buf->add("a");
                     $l = _hx_len($v);
                     $_g1 = 0;
                     while ($_g1 < $l) {
                         $i = $_g1++;
                         if ($v[$i] === null) {
                             $ucount++;
                         } else {
                             if ($ucount > 0) {
                                 if ($ucount === 1) {
                                     $this->buf->add("n");
                                 } else {
                                     $this->buf->add("u");
                                     $this->buf->add($ucount);
                                 }
                                 $ucount = 0;
                             }
                             $this->serialize($v[$i]);
                         }
                         unset($i);
                     }
                     if ($ucount > 0) {
                         if ($ucount === 1) {
                             $this->buf->add("n");
                         } else {
                             $this->buf->add("u");
                             $this->buf->add($ucount);
                         }
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("List"):
                     $this->buf->add("l");
                     $v3 = $v;
                     if (null == $v3) {
                         throw new HException('null iterable');
                     }
                     $__hx__it = $v3->iterator();
                     while ($__hx__it->hasNext()) {
                         unset($i1);
                         $i1 = $__hx__it->next();
                         $this->serialize($i1);
                     }
                     $this->buf->add("h");
                     break;
                 case _hx_qtype("Date"):
                     $d = $v;
                     $this->buf->add("v");
                     $this->buf->add($d->getTime());
                     break;
                 case _hx_qtype("haxe.ds.StringMap"):
                     $this->buf->add("b");
                     $v4 = $v;
                     if (null == $v4) {
                         throw new HException('null iterable');
                     }
//.........这里部分代码省略.........
开发者ID:kevinresol,项目名称:mvc-platform-test,代码行数:101,代码来源:Serializer.class.php

示例2: write

 public function write($k, $v)
 {
     if ($this->replacer !== null) {
         $v = $this->replacer($k, $v);
     }
     $_g = Type::typeof($v);
     switch ($_g->index) {
         case 8:
             $this->buf->add("\"???\"");
             break;
         case 4:
             $this->fieldsString($v, Reflect::fields($v));
             break;
         case 1:
             $v1 = $v;
             $this->buf->add($v1);
             break;
         case 2:
             $v2 = null;
             if (Math::isFinite($v)) {
                 $v2 = $v;
             } else {
                 $v2 = "null";
             }
             $this->buf->add($v2);
             break;
         case 5:
             $this->buf->add("\"<fun>\"");
             break;
         case 6:
             $c = _hx_deref($_g)->params[0];
             if (is_object($_t = $c) && !$_t instanceof Enum ? $_t === _hx_qtype("String") : $_t == _hx_qtype("String")) {
                 $this->quote($v);
             } else {
                 if (is_object($_t2 = $c) && !$_t2 instanceof Enum ? $_t2 === _hx_qtype("Array") : $_t2 == _hx_qtype("Array")) {
                     $v3 = $v;
                     $this->buf->b .= "[";
                     $len = $v3->length;
                     $last = $len - 1;
                     $_g1 = 0;
                     while ($_g1 < $len) {
                         $i = $_g1++;
                         if ($i > 0) {
                             $this->buf->b .= ",";
                         } else {
                             $this->nind++;
                         }
                         if ($this->pretty) {
                             $this->buf->b .= "\n";
                         }
                         if ($this->pretty) {
                             $v4 = null;
                             $c1 = $this->indent;
                             $l = $this->nind * strlen($this->indent);
                             if (strlen($c1) === 0 || strlen("") >= $l) {
                                 $v4 = "";
                             } else {
                                 $v4 = str_pad("", Math::ceil(($l - strlen("")) / strlen($c1)) * strlen($c1) + strlen(""), $c1, STR_PAD_LEFT);
                             }
                             unset($l, $c1);
                             $this->buf->add($v4);
                             unset($v4);
                         }
                         $this->write($i, $v3[$i]);
                         if ($i === $last) {
                             $this->nind--;
                             if ($this->pretty) {
                                 $this->buf->b .= "\n";
                             }
                             if ($this->pretty) {
                                 $v5 = null;
                                 $c2 = $this->indent;
                                 $l1 = $this->nind * strlen($this->indent);
                                 if (strlen($c2) === 0 || strlen("") >= $l1) {
                                     $v5 = "";
                                 } else {
                                     $v5 = str_pad("", Math::ceil(($l1 - strlen("")) / strlen($c2)) * strlen($c2) + strlen(""), $c2, STR_PAD_LEFT);
                                 }
                                 unset($l1, $c2);
                                 $this->buf->add($v5);
                                 unset($v5);
                             }
                         }
                         unset($i);
                     }
                     $this->buf->b .= "]";
                 } else {
                     if (is_object($_t3 = $c) && !$_t3 instanceof Enum ? $_t3 === _hx_qtype("haxe.ds.StringMap") : $_t3 == _hx_qtype("haxe.ds.StringMap")) {
                         $v6 = $v;
                         $o = _hx_anonymous(array());
                         if (null == $v6) {
                             throw new HException('null iterable');
                         }
                         $__hx__it = $v6->keys();
                         while ($__hx__it->hasNext()) {
                             unset($k1);
                             $k1 = $__hx__it->next();
                             $value = $v6->get($k1);
                             $o->{$k1} = $value;
                             unset($value);
//.........这里部分代码省略.........
开发者ID:sp-ruben-simon,项目名称:daff-php,代码行数:101,代码来源:JsonPrinter.class.php


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