Does int mean integer in php?

WBOY
Release: 2023-03-15 17:50:02
Original
19766 people have browsed it

int in PHP means integer. int is the abbreviation of "Integer", which means integer and integer type. It is one of the basic data types of PHP. Integer type only contains integers, including positive and negative numbers, that is, numbers without decimal parts or decimal points. Integer values int can be represented in decimal, hexadecimal, octal or binary.

Does int mean integer in php?

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer

Does int in php mean an integer?

Int in php means integer

Integer type (Integer)

Integer type only contains integers, including positive and negative numbers, that is, there is no decimal part or Numbers with decimal points.

int is a number in the set ℤ = {..., -2, -1, 0, 1, 2, ...}.

They can be decimal (base 10), octal (base 8) or hexadecimal (base 16). The default base is decimal (base 10). Octal integers can be declared with leading 0, and hexadecimal integers can be declared with leading 0x. The integer range must be between -2^31 and 2^31.

Integer value int can be expressed in decimal, hexadecimal, octal or binary, and can be preceded by an optional symbol (- or ). You can use the negative operator to represent a negative int.

To use octal expression, 0 (zero) must be added before the number. Starting from PHP 8.1.0, octal expressions can also be preceded by 0o or 0O . To use hexadecimal representation, the number must be preceded by 0x. To use binary representation, the number must be preceded by 0b.

Starting from PHP 7.4.0, integer values ​​may contain underscores (_). For a better reading experience, these underscores will be filtered out by PHP when displayed.

Examples are as follows:

<?php 
$a = 1234; // 十进制数
$a = 0123; // 八进制数 (等于十进制 83)
$a = 0o123; // 八进制数 (PHP 8.1.0 起)
$a = 0x1A; // 十六进制数 (等于十进制 26)
$a = 0b11111111; // 二进制数字 (等于十进制 255)
$a = 1_234_567; // 整型数值 (PHP 7.4.0 以后)
?>
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Does int mean integer in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template