This article mainly introduces the usage of php floatval() function. I hope it will be helpful to friends in need!
floatval() function is a built-in function in PHP that returns the floating point value of a variable.
Syntax:
float floatval ( $var )
Parameters:
This function accepts one required parameter, as described below:
$var: will return its corresponding floating point value Variables. This variable should not be an object.
Return value: Returns the floating point value of the given variable. Returns 0 for an empty array and 1 for a non-empty array.
Note: If an object is passed to a function, an E_NOTICE level error is raised and 1 is returned.
floatval() function usage code example 1:
<?php $var = '41.68127E3'; $float_value = floatval($var); echo $float_value; ?>
Output:
41681.27
floatval() function usage code example 2:
<?php $var = '47.129mln'; $float_value = floatval($var); echo $float_value; ?>
Output:
47.129
Related recommendations: "PHP Tutorial"
The above is the detailed content of Detailed explanation of the usage of php floatval() function. For more information, please follow other related articles on the PHP Chinese website!