Home > Backend Development > PHP Problem > How to convert decimal in php

How to convert decimal in php

藏色散人
Release: 2023-03-14 21:24:01
Original
3316 people have browsed it

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

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

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!

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