In this article, you will learn how to get the floating value of a variable in PHP. The floatval() function in PHP returns the float value of a variable.
what is the syntax of the FLOATVAL() function in php?
floatval(variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check. Must be a scalar type |
examples of the FLOATVAL() function
Example 1. In this example, we get the float value of different variables.
<?php
$a = "1234.56789";
echo floatval($a) . "<br>";
$b = "1234.56789Hello";
echo floatval($b) . "<br>";
$c = "Hello1234.56789";
echo floatval($c) . "<br>";
?>