PHP is_float Function PHP

PHP is_float Function  

PHP is_float Function

PHP is_float Function

By using this function, we can check that the input value is float or not. This function was introduced in PHP 4.0.

Syntax

  1. bool is_float ( mixed $var )  

Parameters

Parameter Description Is compulsory
var The variable being evaluated. compulsory

Return type:

The is_float() function returns TRUE if the var_name is float, otherwise false.

Example 1

  1. <?php  
  2.     $x=123.41;  
  3.     echo is_float($x);  
  4. ?>  

Output:

PHP variable handling is_float Function

Example 2

  1. <?php  
  2.     $a=123.41;  
  3.     $b=12;  
  4.     var_dump (is_float($a));  
  5.     var_dump (is_float($b));  
  6. ?>  

Output:

PHP variable handling is_float Function

Example 3

  1. <?php  
  2.     $var_name=126.56;  
  3.     if (is_float($var_name))  
  4.     echo 'This is a float value.<br>';  
  5.     else  
  6.     echo 'This is not a float value.<br>';  
  7.     var_dump(is_float('javatpoint'));  
  8.     echo '<br>';  
  9.     var_dump(is_float(85));  
  10. ?>  

Output:

PHP variable handling is_float Function 

Precision::

It is a configuration setting in php.ini used to specify a total number of digits displayed in floating point number.

Here it is:

PHP variable handling is_float Function

Download free E-book of PHP


#askProgrammers
Learn Programming for Free


Join Programmers Community on Telegram


Talk with Experienced Programmers


Just drop a message, we will solve your queries