Home  >  Article  >  Backend Development  >  How to convert decimal in php

How to convert decimal in php

藏色散人
藏色散人Original
2022-01-19 11:28:353251browse

How to convert decimal in php: 1. Create a PHP sample file; 2. Use the "float floatval (mixed $var)" method to convert.

How to convert decimal in php

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!

Statement:
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