Learn PHP Integer Data type:
In PHP integers can be decimal which is a normal number we use in our daily life (base of this number system is 10), an octal number (base of this number system is 8), and hexadecimal (base of this number system is 16).
To denote an octal number in PHP use 0 before the number, and to denote a hexadecimal number use 0x before the number.
Maximum size of the integer data type is platform dependent. Usually the size of integer is 2 million in 32 bit platforms whereas 64 bit platform supports upto 9E18.
If a variable got more than the supported range of integer then it would be converted to float data type.
PHP Integer Data Type Example:
<?php
$a
=12;echo
"\$a=";var_dump($a);echo "<br/>";$a
=-12;echo
"\$a=";var_dump($a);echo "<br/>";$a
=0123;echo
"\$a=";var_dump($a);echo "<br/>";$a
=0x234;echo
"\$a=";var_dump($a);echo "<br/>";$a
= 2147483647;echo
"\$a=";var_dump($a);echo "<br/>";$a
= 2147483648;echo
"\$a=";var_dump($a);echo "<br/>";?>
Output:
$a=int(12)If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.