Table of Contents

    Floats in PHP: Handling Decimal Numbers

    Floats in PHP: Handling Decimal Numbers

    A float (a floating-point number) is a number with a decimal point or a number in exponential form.

    In the following example, $x is a float. The PHP var_dump() function returns the data type and value:

    Example Code:

    
    <?php
    
    $x = 10.365;
    var_dump($x);
    
    ?>
    
    

    Output:

    The above code will produce the following result-

    
    float(10.365)