PHP floatval() Function
❮ PHP Variable Handling Reference
Example
Return 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>";
?>
Try it Yourself »
Definition and Usage
The floatval() function returns the float value of a variable.
Syntax
floatval(variable);
Parameter Values
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check. Must be a scalar type |
Technical Details
Return Value: | The float value of the variable on success, 0 on failure. An empty array will return 0, and a non-empty array will return 1 |
---|---|
Return Type: | Float |
PHP Version: | 4.2 |
❮ PHP Variable Handling Reference