is_floatCHECK if a given
VARIABLE is or is not a floating point
DECIMAL VALUE.
Aliases:
is_double.
is_double
CHECK if a given VARIABLE is or is not a floating point DECIMAL VALUE.
Aliases: is_float.
is_realCHECK if a given
VARIABLE is or is not a floating point
DECIMAL VALUE.
Aliases:
is_float,
is_double.
This alias is DEPRECATED in PHP 7.4.0
and
REMOVED as of PHP 8.0.0.
This function returns a true on success or false on failure.
One way to visualize the test result is to use var_dump, however, it is better to use one for the if options as a conditional evaluation framework.
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Aliases:
is_float and is_double
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
bool is_float ( mixed $value );
where,
$value = VARIABLE to test
?>
$value
The variable to test.
EXERCISE
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
var_dump
to display the variable as is
- - - - - - - - - - - - - - - - - - - - - - - */
var_dump($_SERVER['REMOTE_ADDR']);
echo '<br><br>';
var_dump($_SERVER['HTTP_USER_AGENT']);
echo '<br><br>';
var_dump($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo '<br><br>';
var_dump(M_E);
echo '<br><br>';
$x04p = 1.6e-19;
var_dump($x04p);
$arr07 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
echo '<br><br>';
var_dump($arr07);
$varN01 = NULL;
echo '<br><br>';
var_dump($varN01);
echo '<br><br>';
$varI0 = 123456;
var_dump($varI0);
?>
EXERCISE
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
an user-defined function
to display if the variable
is a FLOAT
Aliases:
is_float, is_double
- - - - - - - - - - - - - - - - - - - - - - - */
$var01 = $_SERVER['REMOTE_ADDR'];
$var02 = $_SERVER['HTTP_USER_AGENT'];
$var03 = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var04 = M_E;
$x04p = 1.6e-19;
$arr07 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$varN01 = NULL;
$varI0 = 123456;
$varI1 = '123456';
$x09f = 5.567_076-10;
function isfloat($var)
{
if(is_float($var))
// if(is_double($var));
{
var_dump($var);
echo '<br>is FLOAT<br><br>';
}
else
{
var_dump($var);
echo '<br>is NOT FLOAT<br><br>';
}
}
isfloat($var01);
isfloat($var02);
isfloat($var03);
isfloat($var04);
isfloat($x04p);
isfloat($arr07);
isfloat($varN01);
isfloat($varI0);
isfloat($varI1);
isfloat($x09f);
?>