Home > Article > Backend Development > How to convert decimal in php
How to convert decimal in php: 1. Create a PHP sample file; 2. Use the "float floatval (mixed $var)" method to convert.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
php How to convert decimal?
How to convert php string to decimal type
Use floatval function to convert
float floatval ( mixed $var )
Return the float value of variable var.
var can be any scalar type. You cannot use floatval() with arrays or objects.
$var = '122.34343The'; $float_value_of_var = floatval ($var); print $float_value_of_var; // 打印出 122.34343
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert decimal in php. For more information, please follow other related articles on the PHP Chinese website!