How to convert string to floating point in php

王林
Release: 2023-03-04 20:54:02
Original
3813 people have browsed it

php method to convert a string to a floating point type: first save a string type decimal in the $str variable; then use float to force the string type to a floating point type; finally use gettype () function can obtain the converted variable type.

How to convert string to floating point in php

First save a string type decimal in the $str variable;

(Recommended tutorial:php graphic tutorial)

Then use float to force the string type to a floating point type, and save the result in the $res variable;

Finally use the gettype() function to obtain the converted Variable type, and use echo to output the result.

(Video tutorial recommendation:php video tutorial)

Code implementation:

How to convert string to floating point in php

Output results :

How to convert string to floating point in php##

The above is the detailed content of How to convert string to floating point 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!