In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how php forces values to be numeric types". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how php forces values to numeric types".
Conversion method: 1, in front of the variable enclosed in parentheses with the target type "(int)", syntax "(int) $val"; 2, the use of intval () function, syntax "intval ($val)"; 3, the use of settype (), syntax "settype ($val," integer ")".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php forces values to be numeric
Method 1: add the target type "(int)" or "(integer)" enclosed in parentheses before the variable to be converted
Method 2: use the specific conversion function intval ()
The intval () function is used to get the integer value of a variable.
The intval () function returns the integer value of the variable var by using the specified binary base conversion (the default is decimal). Intval () cannot be used for object, otherwise an E_NOTICE error will be generated and 1 will be returned.
Method 3: use the settype () function
Description:
The settype () function sets the variable $var to the specified $type type. Syntax:
Settype ($var, $type)
The value that can be set for $type:
"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)
The settype () function changes the type of the variable itself.
At this point, I believe you have a deeper understanding of "php how to force values to numeric types". 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.