PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

is_int> <is_double
Last updated: Fri, 01 Jun 2007

view this page in

is_float

(PHP 4, PHP 5)

is_float — Finds whether a variable is a float

Description

bool is_float ( mixed $var )

Finds whether the given variable is a float.

Note: To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().

Parameters

var

The variable being evaluated.

Return Values

Returns TRUE if var is a float, FALSE otherwise.

See Also

is_bool()
is_int()
is_numeric()
is_string()
is_array()
is_object()



add a note add a note User Contributed Notes
is_float
phper
25-Jan-2006 08:08
A better way to check for a certain number of decimal places is to use :

$num_dec_places = 2;
number_format($value,$num_dec_places);
kirti dot contact at gmail dot com
19-Oct-2005 06:18
To check a float only should contain certain number of decimal places, I have used this simple function below

<?
function is_deccount($number,$decimal=2){
   
$m_factor=pow(10,$decimal);
    if((int)(
$number*$m_factor)==$number*$m_factor)
        return
true;
    else
        return
false;
 }   
?>

is_int> <is_double
Last updated: Fri, 01 Jun 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites