Home >Backend Development >PHP Problem >How to represent integers in php
PHP Integers
Integers are numbers without decimals.
Integer rules:
The integer must have at least one digit (0-9)
The integer cannot contain commas or spaces
Integers cannot have decimal points
Integers can be positive or negative (recommended learning:PHP programming from entry to proficiency)
Integers can be specified in three formats: decimal , hexadecimal (prefix is 0x) or octal (prefix is 0)
In the following example, we will test different numbers. PHP var_dump() will return the data type and value of the variable:
Example
<!DOCTYPE html> <html> <body> <?php $x = 5985; var_dump($x); echo "<br>"; $x = -345; // 负数 var_dump($x); echo "<br>"; $x = 0x8C; // 十六进制数 var_dump($x); echo "<br>"; $x = 047; // 八进制数 var_dump($x); ?> </body> </html>
The above is the detailed content of How to represent integers in php. For more information, please follow other related articles on the PHP Chinese website!