Summary: in this tutorial, you’ll learn about the PHP int type that represents integers in PHP.
Bạn đang xem: Php, how to convert a string into number in php
Integers are whole numbers such as -3, -2, -1, 0, 1, 2, 3… PHP uses the int type to lớn represent the integers.
The range of integers depends on the platform where PHP runs. Typically, integers has a range from -2,147,438,648 khổng lồ 2,147,483,647. It’s equivalent to 32 bits signed.
To get the size of the integer, you use the PHP_INT_SIZE constant. Also, you use the PHP_INT_MIN & PHP_INT_MAX constants khổng lồ get the minimum & maximum integer values.
Xem thêm: Sửa Lỗi Bàn Phím Gta 5, Grand Theft Auto V Và Cách Khắc Phục
PHP represents integer literals in decimal, octal, binary, và hexadecimal formats.
PHP uses a sequence of digits without leading zeros to lớn represent decimal values. The sequence may begin with a plus or minus sign. If it has no sign, then the integer is positive. For example:
2000-10012345
From PHP 7.4, you can use the underscores (_) to lớn group digits in an integer lớn make it easier to read. For example, instead of using the following number:
1000000
you can use the underscores (_) to lớn group digits lượt thích this:
1_000_000
+010 // decimal 8
Code language: JavaScript (javascript)
Similar to decimal numbers, hexadecimal numbers can include a sign, either plus (+) or minus(-). For example:
0x10 // decimal 160xFF // decimal 255
Code language: JSON / JSON with Comments (json)
0b10 // decimal 2
Code language: JavaScript (javascript)
$amount = 100;echo is_int($amount);
Code language: PHP (php)Output: