is_double()
The is_double() function is a deprecated alias of the is_float() function in PHP. It checks whether a variable is a float or not. A float is a data type that
Introduction
is_double() was an alias of is_float() that checks whether a variable holds a floating-point number. A float (also called a double) is the data type PHP uses for numbers with a fractional part, such as 3.14 or 1.0e6.
Important:
is_double()was deprecated long ago and removed in PHP 8.0.0. In any PHP version, preferis_float()— it is identical in behavior, supported, and clearer to read. This page documentsis_double()so you can recognize and migrate legacy code that still uses it.
This chapter covers the syntax, what counts as a float, how the return value behaves, the recommended replacement, and the common gotchas.
Syntax
is_double(mixed $value): boolIt takes one parameter, $value, the variable to test, and returns true if $value is of type float, false otherwise. The check is on the type, not on whether the number looks decimal — see the gotchas below.
What counts as a float
is_double() (and is_float()) returns true only when the variable's runtime type is float. Numeric strings and whole-number integers are not floats:
<?php
var_dump(is_float(3.14)); // bool(true)
var_dump(is_float(1.0e6)); // bool(true) — scientific notation is a float
var_dump(is_float(42)); // bool(false) — this is an int
var_dump(is_float("3.14")); // bool(false) — this is a string
var_dump(is_float(10 / 2)); // bool(true) — division always yields a float in PHP
?>Note that 10 / 2 is true: in PHP, the / operator always produces a float, even when the result is mathematically a whole number.
Example Usage
Because echoing booleans is misleading (true prints 1, false prints nothing), use var_dump() to see the real result:
$price is a genuine float, so the check is true. $count is an integer and $label is a string, so both are false.
The modern replacement: is_float()
Replacing is_double() is a straight rename — the arguments and return value are the same:
<?php
// Legacy (removed in PHP 8.0)
// if (is_double($value)) { ... }
// Modern, supported everywhere
$value = 9.99;
if (is_float($value)) {
echo "It's a float";
}
?>If you need to accept numbers that might be a float, an int, or a numeric string (for example, form input), reach for is_numeric() instead, or convert with floatval().
Common gotchas
- Numeric strings fail the check.
is_float("3.14")isfalse. User input from forms or$_GETarrives as strings; validate withis_numeric()first, then cast withfloatval(). - Don't compare floats for exact equality. Because of binary rounding,
0.1 + 0.2 == 0.3isfalse. Compare within a small tolerance instead. is_doubleis dead in PHP 8+. Calling it on PHP 8.0 or later raises a fatalError: Call to undefined function is_double().
See also
is_float()— the current, supported function.is_int()— test for integers.is_numeric()— test for numbers or numeric strings.floatval()— convert a value to a float.gettype()— inspect a variable's type directly.
Conclusion
is_double() is a removed alias of is_float(). For new code, always use is_float() to test whether a value is a floating-point number, and only keep is_double() in mind so you can update legacy projects when you migrate them to PHP 8 or later.