Saturday, May 16, 2026
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
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS