Skip to content
Related Articles

Related Articles

PHP | is_double() Function
  • Last Updated : 21 Apr, 2020

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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' 
  
?> 

chevron_right


Output:

1


1

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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"
?> 

chevron_right


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

My Personal Notes arrow_drop_up
Recommended Articles
Page :