Home  >  Article  >  Backend Development  >  How to convert string to floating point in php

How to convert string to floating point in php

王林
王林Original
2020-08-20 13:29:413909browse

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!

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