本文整理汇总了PHP中is_double函数的典型用法代码示例。如果您正苦于以下问题:PHP is_double函数的具体用法?PHP is_double怎么用?PHP is_double使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_double函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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"}));
}
}
}
}
示例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]));
}
示例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;
}
示例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;
}
示例6: isHourValid
public function isHourValid($hour)
{
if (!is_numeric($hour) || is_double($hour) || $hour < 0) {
return false;
}
return true;
}
示例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
}
}
}
}
}
}
示例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();
}
示例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;
}
示例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);
}
示例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');
}
示例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";
}
}
}
}
示例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;
}
}
示例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;
}
示例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>";
}