Home > Database > Mysql Tutorial > body text

What does 'int(11)' mean in web programming tutorials and how does it differ from other variations like 'int(10)' or 'int(4)'?

Barbara Streisand
Release: 2024-11-16 15:52:03
Original
440 people have browsed it

What does

Understanding int(11) vs. int(Anything Else)

While exploring web programming tutorials, the concept of int(11) and its variations (int(10), int(4), etc.) can raise questions. Originally, int(11) represents a maximum display width of 11 characters for integers, unless specified as UNSIGNED (in which case it defaults to 10). However, other values may be encountered in different tutorials, leaving you wondering about their purpose.

Unlike space requirements or performance considerations, the x in INT(x) specifically refers to the display width. By reducing this width, tutorials aim to achieve a "ZEROFILL" option for UNSIGNED integers. This option ensures that values are left-padded with zeros to the specified display width.

For example, consider the following:

INT(4) UNSIGNED ZEROFILL

Value Result
1 0001
2 0002
99 0099
1000 0100
10000 1000

INT(2) UNSIGNED ZEROFILL

Value Result
1 01
2 02
9 09
10 10
100 10

In contrast, without the ZEROFILL option, values will be left-padded with spaces:

INT(4)

Value Result
1 1
2 2
99 99
1000 1000
10000 10000

INT(2)

Value Result
1 1
2 2
9 9
10 10
100 10

By adjusting the display width, tutorials demonstrate the use of the ZEROFILL option to enhance the formatting and presentation of unsigned integer values.

The above is the detailed content of What does 'int(11)' mean in web programming tutorials and how does it differ from other variations like 'int(10)' or 'int(4)'?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template