• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_double函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fromUpperDecimal

 /**
  * Creates new Tax from a upper decimal value.
  * I.e. value must be '1.22' for a tax of '22%'.
  *
  * @param double $lowerDecimal
  * @return Tax
  * @throws InvalidArgumentException
  */
 public static function fromUpperDecimal($upperDecimal)
 {
     if (!is_double($upperDecimal)) {
         throw new InvalidArgumentException('$upperDecimal must be a double, but ' . $upperDecimal . ' given.');
     }
     return new TaxImpl($upperDecimal);
 }
开发者ID:o5,项目名称:eciovni,代码行数:15,代码来源:TaxImpl.php


示例2: testGetPaymentTypes

 public function testGetPaymentTypes()
 {
     $cougarCashClient = new \clients\cougar_cash();
     $result = $cougarCashClient->getPaymentTypes();
     if (count($result->{"payment_types"}) > 0) {
         foreach ($result->{"payment_types"} as $paymentType) {
             if ($paymentType->{"account_type"} == "CREDIT_CARD") {
                 $this->assertTrue(is_string($paymentType->{"id"}));
                 $this->assertTrue(is_string($paymentType->{"nickname"}));
                 $this->assertTrue(is_string($paymentType->{"munged_account_num"}));
                 $this->assertTrue(substr($paymentType->{"munged_account_num"}, 0, 1) === "*");
                 $this->assertTrue(is_string($paymentType->{"financial_institution"}));
                 $this->assertTrue(is_int($paymentType->{"minimum"}));
                 $this->assertTrue(is_int($paymentType->{"maximum"}));
                 $this->assertTrue(is_double($paymentType->{"min_fee"}));
                 $this->assertTrue(is_double($paymentType->{"fee_percent"}));
             } elseif ($paymentType->{"account_type"} == "BANK_ACCOUNT") {
                 $this->assertTrue(is_string($paymentType->{"id"}));
                 $this->assertTrue(is_string($paymentType->{"nickname"}));
                 $this->assertTrue(is_string($paymentType->{"munged_account_num"}));
                 $this->assertTrue(substr($paymentType->{"munged_account_num"}, 0, 1) === "*");
                 $this->assertTrue(is_string($paymentType->{"financial_institution"}));
                 $this->assertTrue(is_int($paymentType->{"minimum"}));
                 $this->assertTrue(is_int($paymentType->{"maximum"}));
             }
         }
     }
 }
开发者ID:byu-oit-appdev,项目名称:cougarCashPhpClientTests,代码行数:28,代码来源:cougar_cashTest.php


示例3: testCanSearchAddress

 public function testCanSearchAddress()
 {
     $latAndLong = $this->geocoder->getGeocodedLatitudeAndLongitude('12 Girouard, Montreal, Quebec');
     $this->assertTrue(is_array($latAndLong));
     $this->assertTrue(is_double($latAndLong[0]));
     $this->assertTrue(is_double($latAndLong[1]));
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:7,代码来源:GeocodingAdapterTest.php


示例4: recursiveQuote

 protected function recursiveQuote($val)
 {
     if (is_array($val)) {
         $return = array();
         foreach ($val as $v) {
             $return[] = $this->recursiveQuote($v);
         }
         return '(' . implode(',', $return) . ')';
     } else {
         if (is_null($val)) {
             $val = 'NULL';
         } else {
             if (is_int($val)) {
                 $val = (int) $val;
             } else {
                 if (is_double($val)) {
                     $val = (double) $val;
                 } else {
                     if (is_float($val)) {
                         $val = (double) $val;
                     } else {
                         $val = "'" . Convert::raw2sql($val) . "'";
                     }
                 }
             }
         }
     }
     return $val;
 }
开发者ID:nyeholt,项目名称:silverstripe-external-content,代码行数:29,代码来源:ECUtils.php


示例5: prepare

 /**
  * @param $sql
  * @param $params
  * @return mixed
  */
 private function prepare($sql, $params)
 {
     $escaped = '';
     if ($params) {
         foreach ($params as $key => $value) {
             if (is_bool($value)) {
                 $value = $value ? 1 : 0;
             } elseif (is_double($value)) {
                 $value = str_replace(',', '.', $value);
             } elseif (is_numeric($value)) {
                 if (is_string($value)) {
                     $value = "'" . $this->provider->escape($value) . "'";
                 } else {
                     $value = $this->provider->escape($value);
                 }
             } elseif (is_null($value)) {
                 $value = "NULL";
             } else {
                 $value = "'" . $this->provider->escape($value) . "'";
             }
             $escaped[] = $value;
         }
     }
     $this->params = $escaped;
     $q = preg_replace_callback("/(\\?)/i", array($this, "replaceParams"), $sql);
     return $q;
 }
开发者ID:elephantphp,项目名称:ElephantFreamwork,代码行数:32,代码来源:Database.php


示例6: isHourValid

 public function isHourValid($hour)
 {
     if (!is_numeric($hour) || is_double($hour) || $hour < 0) {
         return false;
     }
     return true;
 }
开发者ID:b4t3ou,项目名称:due_date_calculator,代码行数:7,代码来源:Validator.php


示例7: where

 public function where($where, $val = null)
 {
     $where = $this->escape($where);
     if ($val === true) {
         $this->where_list[] = $where . " = 'TRUE'";
     } else {
         if ($val === false) {
             $this->where_list[] = $where . " = 'FALSE'";
         } else {
             if ($val === null) {
                 $this->where_list[] = $where;
             } else {
                 if (is_string($val)) {
                     $this->where_list[] = $where . " = '" . $this->escape($val) . "'";
                 } else {
                     if (is_int($val) || is_float($val) || is_double($val)) {
                         $this->where_list[] = $where . ' = ' . $this->escape($val);
                     } else {
                         $this->where_list[] = $where . " = '" . $this->escape($val) . "'";
                         # default
                     }
                 }
             }
         }
     }
 }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:26,代码来源:rude-iquery.php


示例8: testCGet

 public function testCGet()
 {
     $client = static::createClient();
     $crawler = $client->request('GET', '/api/charges');
     $this->assertTrue($client->getResponse()->headers->contains('Content-Type', 'application/json'));
     $json = json_decode($client->getResponse()->getContent());
     $this->assertNotNull($json, $client->getResponse()->getContent());
     $this->assertEquals($json->{'error'}, "success");
     $this->assertInternalType("array", $json->{'charges'});
     foreach ($json->{'charges'} as $charge) {
         $this->assertInternalType("integer", $charge->{'id'});
         if (property_exists($charge, 'description')) {
             $this->assertInternalType("string", $charge->{'description'});
         }
         if (is_double($charge->{'duration'})) {
             $this->assertInternalType("float", $charge->{'duration'});
         } else {
             $this->assertInternalType("integer", $charge->{'duration'});
         }
         $this->assertInternalType("string", $charge->{'created'});
         $this->assertInternalType("object", $charge->{'employee'});
         $this->assertInternalType("object", $charge->{'task'});
         $this->assertFalse(date_create($charge->{'created'}) === FALSE);
     }
     $client->insulate();
 }
开发者ID:pscheyer,项目名称:PlanITJavascript,代码行数:26,代码来源:ChargeControllerTest.php


示例9: __construct

 /**
  * @param double $value
  * @throws Exception
  */
 public function __construct($value)
 {
     if (!is_double($value)) {
         throw new Exception('Incoming value must be of type double.');
     }
     $this->_value = $value;
 }
开发者ID:jippi,项目名称:php-cassandra,代码行数:11,代码来源:Double.php


示例10: assertEquals

 /**
  * Asserts that two variables are equal.
  *
  * @param  mixed  $expected
  * @param  mixed  $actual
  * @param  mixed  $delta
  * @param  string $message
  * @access public
  * @static
  */
 public static function assertEquals($expected, $actual, $delta = 0, $message = '')
 {
     if (is_null($expected) && is_null($actual)) {
         return;
     }
     if (is_object($expected)) {
         if (!is_object($actual) || serialize($expected) != serialize($actual)) {
             self::failNotEquals($expected, $actual, $message);
         }
         return;
     }
     if (is_array($expected)) {
         if (!is_array($actual)) {
             self::failNotEquals($expected, $actual, $message);
         }
         self::sortArrayRecursively($actual);
         self::sortArrayRecursively($expected);
         if (self::$looselyTyped) {
             $actual = self::convertToString($actual);
             $expected = self::convertToString($expected);
         }
         self::assertEquals(serialize($expected), serialize($actual));
         return;
     }
     if ((is_double($expected) || is_float($expected)) && (is_double($actual) || is_float($actual))) {
         if (!(abs($expected - $actual) <= $delta)) {
             self::failNotEquals($expected, $actual, $message);
         }
         return;
     }
     if (self::$looselyTyped) {
         settype($actual, gettype($expected));
     }
     self::assertSame($expected, $actual, $message);
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:45,代码来源:Assert.php


示例11: add

 /**
  * This method adds the passed object with the passed key
  * to the HashMap.
  *
  * @param mixed $key    The key to add the passed value under
  * @param mixed $object The object to add to the HashMap
  *
  * @return \AppserverIo\Collections\HashMap The instance
  * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an primitive datatype
  * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is null or not a flat datatype like Integer, Strng, Double or Boolean
  */
 public function add($key, $object)
 {
     if (is_null($key)) {
         throw new NullPointerException('Passed key is null');
     }
     // check if a primitive datatype is passed
     if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) {
         // add the item to the array
         $this->items[$key] = $object;
         // and return
         return;
     }
     // check if an object is passed
     if (is_object($key)) {
         if ($key instanceof Strng) {
             $newKey = $key->stringValue();
         } elseif ($key instanceof Flt) {
             $newKey = $key->floatValue();
         } elseif ($key instanceof Integer) {
             $newKey = $key->intValue();
         } elseif ($key instanceof Boolean) {
             $newKey = $key->booleanValue();
         } elseif (method_exists($key, '__toString')) {
             $newKey = $key->__toString();
         } else {
             throw new InvalidKeyException('Passed key has to be a primitive datatype or  has to implement the __toString() method');
         }
         // add the item to the array
         $this->items[$newKey] = $object;
         // and return
         return;
     }
     throw new InvalidKeyException('Passed key has to be a primitive datatype or  has to implement the __toString() method');
 }
开发者ID:appserver-io,项目名称:collections,代码行数:45,代码来源:HashMap.php


示例12: unary

 public function unary($la)
 {
     for ($i = 0; $i < 3; $i++) {
         foreach ($la as $l) {
             if (is_int($l)) {
                 echo "{$l} is_int\n";
             }
             if (is_string($l)) {
                 echo "{$l} is_string\n";
             }
             if (is_double($l)) {
                 echo "{$l} is_double\n";
             }
             if (is_null($l)) {
                 echo "{$l} is_null\n";
             }
             if (is_double($l)) {
                 echo "{$l} is_double\n";
             }
             if (is_array($l)) {
                 echo "{$l} is_array\n";
             }
             if (is_object($l)) {
                 echo "{$l} is_object\n";
             }
         }
     }
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:28,代码来源:allbranches.php


示例13: AddParameter

 private function AddParameter(&$params, &$types, $this_param)
 {
     if (is_array($this_param) === true && count($this_param) > 0) {
         // recurse into any number of nested arrays as necessary
         foreach ($this_param as $this_parameter) {
             self::AddParameter($params, $types, $this_parameter);
         }
     } else {
         if (is_string($this_param)) {
             $types[] = 's';
         } else {
             if (is_int($this_param)) {
                 $types[] = 'i';
             } else {
                 if (is_double($this_param)) {
                     $types[] = 'd';
                 } else {
                     $types[] = 's';
                     // string as default
                 }
             }
         }
         $params[] = $this_param;
     }
 }
开发者ID:jarek,项目名称:take-the-grt,代码行数:25,代码来源:Database.php


示例14: query

 public function query($query, $parameters = NULL)
 {
     $this->open_connection();
     $statement = $this->conn->prepare($query);
     if ($statement) {
         if (!is_null($parameters) && count($parameters) > 0) {
             foreach ($parameters as $parameter) {
                 if (is_integer($parameter)) {
                     $statement->bind_param("i", $parameter);
                 } elseif (is_double($parameter)) {
                     $statement->bind_param("d", $parameter);
                 } elseif (is_string($parameter)) {
                     $statement->bind_param("s", $parameter);
                 }
             }
         }
         $statement->execute();
         $result = $statement->get_result();
         $statement->close();
     } else {
         $log->error("Error preparing statement of query " . $query);
     }
     $this->close_connection();
     return $result;
 }
开发者ID:juanpmd,项目名称:Seek-Inspire,代码行数:25,代码来源:DB.php


示例15: _xmlType

 protected function _xmlType($value)
 {
     if (is_string($value)) {
         return "<string>{$value}</string>";
     } else {
         if (is_int($value)) {
             return "<int>{$value}</int>";
         } else {
             if (is_double($value)) {
                 return "<double>{$value}</double>";
             } else {
                 if (is_array($value) && count($value) > 0) {
                     $r = "<struct>\n";
                     foreach ($value as $n => $v) {
                         $r .= "\t<member>\n";
                         $r .= "\t\t<name>{$n}</name>\n";
                         $r .= "\t\t<value>{$this->_xmlType($v)}</value>\n";
                         $r .= "\t</member>\n";
                     }
                     return "{$r}\n</struct>\n";
                 }
             }
         }
     }
     return "<string><![[{$value}]]></string>";
 }
开发者ID:andelux,项目名称:landingpages,代码行数:26,代码来源:Wordpress.php


示例16: isScalar

 public function isScalar()
 {
     if (!is_float($this->getContent()) || !is_double($this->getContent())) {
         $this->add(ErrorCode::MUST_BE_SCALAR_ERROR_CODE);
     }
     return $this;
 }
开发者ID:waspframework,项目名称:waspframework,代码行数:7,代码来源:NumericType.php


示例17: chiSquare

 /**
  * Compute chiSquare test value from array of observations
  * and expected probabilities of slots.
  *
  * @param array(int) $observedCnt observed counts
  * @param array(double) $expectedProb expected probabilities
  *
  * @returns double chi squared
  */
 static function chiSquare(array $observedCnt, array $expectedProb)
 {
     Preconditions::check(count($observedCnt) == count($expectedProb), "number of slots for observations and expectations should match.");
     foreach ($observedCnt as $cnt) {
         Preconditions::check(is_int($cnt), "Observed count should be integer");
     }
     foreach ($expectedProb as $prob) {
         Preconditions::check(is_double($prob), "Probability should be double");
         Preconditions::check(0.0 < $prob && 1.0 > $prob, "Expected probabilities shoud be in range (0,1).");
     }
     Preconditions::check(abs(array_sum($expectedProb) - 1) < 1.0E-6, "Probabilities does not sum up to 1");
     $samples = array_sum($observedCnt);
     foreach ($expectedProb as $prob) {
         if ($samples * $prob <= 5) {
             // @see http://en.wikipedia.org/wiki/Pearson's_chi-square_test#Problems
             throw new RuntimeException("You should have more samples for " . "computing Pearson test with specified probabilities");
         }
     }
     $chisqr = 0;
     for ($i = 0; $i < count($observedCnt); $i++) {
         $expected = $expectedProb[$i] * $samples;
         $chisqr += Math::sqr($observedCnt[$i] - $expected) / $expected;
     }
     return $chisqr;
 }
开发者ID:BGCX067,项目名称:fajr-git,代码行数:34,代码来源:PearsonChiSquare.php


示例18: set

 public function set($value)
 {
     if (!is_double($value)) {
         throw new \InvalidArgumentException('Expected double value');
     }
     $this->value = $value;
 }
开发者ID:fpoirotte,项目名称:xrl,代码行数:7,代码来源:Double.php


示例19: showItems

function showItems()
{
    if (count($_SESSION['cart']) == 0) {
        echo "cart is empty";
    } else {
        $cart = $_SESSION['cart'];
        echo "<table border=1>";
        echo "<tr>";
        echo "<td>Product_id</td>";
        echo "<td>Product_name</td>";
        echo "<td>Product_quantity</td>";
        echo "<td>Product_price</td>";
        echo "<td>Total_price</td>";
        echo "</tr>";
        for ($i = 0; $i < count($cart); $i++) {
            echo "<tr>";
            for ($j = 0; $j < count($cart[$i]); $j++) {
                echo "<td>";
                echo $cart[$i][$j] . " ";
                echo "</td>";
                if (is_double($cart[$i][$j])) {
                    $totalcartprice = $totalcartprice + $cart[$i][$j + 1];
                }
            }
            echo "</tr>";
        }
        echo "cart_price: " . $totalcartprice;
        echo "</table>";
    }
}
开发者ID:samdubey,项目名称:ADS,代码行数:30,代码来源:mycart.php


示例20: checkType

 /**
  * Check whether or not $value is a Float object.
  *
  * @throws \InvalidArgumentException If $value is not an instance of Float.
  */
 protected function checkType($value)
 {
     if (is_double($value) !== true) {
         $msg = "The Float Datatype only accepts to store float values.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:hutnikau,项目名称:qti-sdk,代码行数:12,代码来源:Float.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_dst函数代码示例发布时间:2022-05-15
下一篇:
PHP is_domain函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap