In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to convert php strings into floating-point data". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to convert php strings into floating-point data.
Conversion method: 1, add the target type "(float)", "(double)" or "(real)" enclosed in parentheses before the string variable; 2, use the "floatval (string)" statement; 3, use the "settype (string variable," float ")" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Convert php strings to floating-point data
Method 1: precede the string variable with the target type "(float)", "(double)" or "(real)" enclosed in parentheses
(float), (double), (real): convert target variables to floating-point types
Example:
Output result:
Method 2: use the floatval () function
Floatval (): used to get the floating-point value of a variable
Output result:
Method 3: use the settype () function
The settype () function sets the type of variable.
Syntax: settype (mixed & $var, string $type)
$type: the possible value of type is.
"boolean" (or "bool", starting with PHP 4.2.0)
"integer" (or "int", starting with PHP 4.2.0)
"float" (available only after PHP 4.2.0, "double" used in older versions is now disabled)
"string"
"array"
"object"
"null" (since PHP 4.2.0)
Example:
Output:
Note: the settype () function changes the original type of the variable, returning TRUE if the setting is successful and FALSE if it fails.
At this point, I believe you have a deeper understanding of "how to convert php strings into floating-point data". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.