Detailed explanation of the usage of php floatval() function

藏色散人
Release: 2023-04-05 20:22:01
Original
15042 people have browsed it

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 )
Copy after login

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 = &#39;41.68127E3&#39;; 
$float_value = floatval($var); 
echo $float_value; 
?>
Copy after login

Output:

41681.27
Copy after login

floatval() function usage code example 2:

<?php 
$var = &#39;47.129mln&#39;; 
$float_value = floatval($var); 
echo $float_value; 
?>
Copy after login

Output:

47.129
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template