Skip to content

is_double()

Introduction

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 represents a decimal number. Note: This function was removed in PHP 8.0.0. Use is_float() instead.

Syntax

The syntax of the is_double() function is as follows:

The PHP syntax of the is_double()

php
bool is_double(mixed $var)

The function takes a single parameter, $var, which is the variable to be checked for being a float. The function returns true if the variable is a float, and false otherwise. Since PHP 8.0.0, this function has been removed. Use is_float() for modern PHP code.

Example Usage

Here is an example of how to use the is_double() function in PHP:

Example of PHP is_double()

php
<?php
$var1 = 3.14;
$var2 = 42;
echo is_double($var1) . "\n";  // output: 1 (true)
echo is_double($var2) . "\n";  // output: (empty string)
?>

In this example, we define two variables: $var1 is a float with the value of 3.14, and $var2 is an integer. We then use the is_double() function to check whether each variable is a float. The output shows that $var1 is a float (true), while $var2 is not a float (false). Note: In PHP, echoing a boolean false results in an empty string. For debugging, use var_dump() instead.

Conclusion

The is_double() function is a deprecated alias of the is_float() function in PHP, and is no longer recommended for use. It was officially removed in PHP 8.0.0. Instead, developers should use the is_float() function to check whether a variable is a float or not. By using the correct function, developers can ensure that their code is working with the correct data types and avoid errors that may occur when working with mixed data types.

Practice

What is the function of the 'is_double' function in PHP?

Do you find this helpful?

Dual-run preview — compare with live Symfony routes.