In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 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 floating-point to int in php". 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 to convert floating point to int in php.
The method of changing floating point type to int type in php: 1, use intval () function, syntax "intval (floating point data)"; 2, use settype () function, syntax "settype (floating point data, 'integer')".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The way to convert floating-point to int in php:
Method 1: use the intval () function
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.
Syntax:
Int intval (mixed $var [, int $base = 10])
Parameter description:
$var: the numerical value to be converted to integer.
$base: the base used for conversion.
If base is 0, determine which binary to use by examining the format of the var:
Use hexadecimal (hex) if the string includes the prefix of "0x" (or "0X"); otherwise
Use octal (octal) if the string starts with "0"; otherwise
Decimal (decimal) will be used.
Return value: the integer value of var is returned on success and 0 on failure. Empty array returns 0, and non-empty array returns 1.
Example: convert a floating point to an int
Method 2: use the settype () function
The settype () function is used to set the type of variable.
The types that can be set are:
"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)
Note: the settype () function changes the type of the variable itself.
Example: convert a floating point to an int
At this point, I believe you have a deeper understanding of "how to convert floating-point to int in php". 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.