PHP - Datatype Float


PHP - Datatype Float

  • A floating point number is a number with a decimal point or a number in exponential form.
  • Floating point numbers have limited precision.

Syntax :

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

Syntax Explanation :

  • Here $x is a float.
  • $x is a float. The PHP var_dump() function returns the data type float and its float value.

Sample code :

<!DOCTYPE html>
<html>
<head>  
    <title>Datatype-Float</title>
</head>
    <body>
        <?php  
            $a = 0.758;
            var_dump($a);
        ?>  
    </body>
</html>

Code Explanation :


    In PHP, $a = 0.758 is a float variable that holds the value =0.758.

    In PHP, var_dump() this function returns the data type as  float with its float value as 0.758.

Sample Output :


    In this output, var_dump() function returns the float data type with its float value as 0.758 i.e., float(0.758).

Workshop

IOT Hackathon
Webinar

Join our Community

Advertise