What are the functions in php that convert values to floating point types?

青灯夜游
Release: 2023-03-16 11:20:02
Original
2447 people have browsed it

php has two functions to convert values to floating point types: 1. The floatval() function can obtain the floating point value of a variable. It is mainly used to convert variables to floating point types. The syntax "floatval() value)"; 2. The settype() function can set the variable to the specified type. When the second parameter is set to "float", the variable can be set to floating point type. The syntax is "settype($var,"float" )", this function will change the original variable, return TRUE if the setting is successful, and return FALSE if it fails.

What are the functions in php that convert values ​​to floating point types?

The operating environment of this tutorial: windows7 system, PHP8.1 version, DELL G3 computer

php transfers the value There are two functions for floating point types:

  • floatval()

  • settype()

1. Use floatval() to convert the value to floating point type

floatval() is used to obtain the floating point value of the variable, mainly used to convert the value Convert to floating point type.

Copy after login

What are the functions in php that convert values ​​to floating point types?

2. Use settype() to convert the value to floating point type

settype($var,$ type)function is used to set the variable $var to the specified type $type. Returns TRUE if the setting is successful and FALSE if it fails.

When the $type parameter of this function is set to "float", the value can be converted to floating point type.

Note: The settype() function will change the original variable.

Copy after login

What are the functions in php that convert values ​​to floating point types?

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What are the functions in php that convert values to floating point types?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!