w3resource

PHP : is_double() function

Description

The is_double () function is used to test whether a variable is a float or not. The function is an alias of is_float().

Version:

(PHP 4 and above)

Syntax:

is_double (var_name)

Parameter:

Name Description Required /
Optional
Type
var_name The variable being checked Required Mixed*

*Mixed : Mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Return value:

TRUE if var_name is a float, FALSE otherwise.

Value Type: Boolean.

Example:

<?php
$var_name=127.55;
if (is_double($var_name))
echo 'This is a double value.<br>';
else
echo 'This is not a double value.<br>';
echo '<br>';
var_dump(is_double(85));
echo '<br>';
var_dump(is_double(1e8));
echo '<br>';
var_dump(is_double(true));
echo '<br>';
var_dump(is_double(array(23.3, 56, 6)));
?>

Output:

This is a double value.
bool(false)
bool(true) 
bool(false)
bool(false) 

View the example in the browser

Practice here online :

See also

PHP Function Reference

Previous: is_callable
Next: is_float



PHP: Tips of the Day

Returns true if the given string is a palindrome, false otherwise

Example:

<?php
function tips_palindrome($string)
{
  return strrev($string) === (string) $string;
}

print(tips_palindrome('malayalam'));
print("\n");
print(tips_palindrome(151));

?>

Output:

1
1