Friday, October 17, 2025
HomeLanguagesPHP | is_double() Function

PHP | is_double() Function

The is_double() function is an inbuilt function in PHP which is used to find whether the given value is a double or not.

Syntax:

bool is_double( $variable_name )

Parameters: This function accepts one parameter as mentioned above and described below:

  • $variable_name: This parameter holds the value which need to check.

Return Value: It is a boolean value i.e. either TRUE if $variable_name contains is a double value, otherwise returns FALSE.

Below programs illustrate the is_double() function in PHP:

Program 1:




<?php 
// PHP code to implement is_double() 
// function
  
function square($num) 
{ 
    return (is_double($num)); 
} 
  
echo square(9.09) ."\n"; // outputs '1'. 
echo square(FALSE) ."\n"; // gives no output. 
echo square(14) ."\n"; // gives no output. 
echo square(56.30) ."\n"; // outputs '1' 
  
?> 


Output:

1


1

Program 2:




<?php 
// PHP code to implement is_double()
// function
  
$variable_name1 = 67.099; 
$variable_name2 = 32; 
$variable_name3 = "abc"; 
$variable_name4 = FALSE; 
  
// $variable_name1 is double value, gives TRUE 
if (is_double($variable_name1)) 
    echo "$variable_name1 is a double value. \n"; 
else
    echo "$variable_name1 is not a double value. \n"; 
  
// $variable_name2 is not a double value, gives FALSE 
if (is_double($variable_name2)) 
    echo "$variable_name2 is a double value. \n"; 
else
    echo "$variable_name2 is not a double value. \n"; 
  
// $variable_name3 is not a double value, gives FALSE 
if (is_double($variable_name3)) 
    echo "$variable_name3 is a double value. \n"; 
else
    echo "$variable_name3 is not a double value. \n"; 
  
// $variable_name4 is not a double value, gives FALSE 
if (is_double($variable_name4)) 
    echo "FALSE is a double value. \n"; 
else
    echo "FALSE is not a double value. \n"; 
?> 


Output:

67.099 is a double value. 
32 is not a double value. 
abc is not a double value. 
FALSE is not a double value.

Reference: https://www.php.net/manual/en/function.is-double.php

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS