Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is intval in php?

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is intval in php". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is intval in php".

In php, intval means to get the integer value of a variable, a function that converts other types of variables to integer types; this function returns the integer value of the variable by using the specified binary base conversion (the default is decimal), and the syntax "intval ($var,$base)".

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In php, the intval function gets the integer value of a variable. The general intval function is used for data type conversion, which converts strings to integer types. )

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

Returns the integer value of var on success and 0 on failure. Empty array returns 0, and non-empty array returns 1.

The maximum value depends on the operating system. The maximum signed integer range for 32-bit systems is-2147483648 to 2147483647. For example, on such a system, intval ('1000000000000000') returns 2147483647. On 64-bit systems, the maximum signed integer value is 9223372036854775807.

It is possible for a string to return 0, depending on the leftmost character of the string.

Example:

Thank you for your reading, the above is the content of "what is intval in php", after the study of this article, I believe you have a deeper understanding of what is intval in php, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report