Home Tutorial Php Phpbasics Tutorial PHP Integer Data Type

 
 

Share on Google+Share on Google+
PHP Integer Data Type
Posted on: March 6, 2010 at 12:00 AM
Advertisement
In this PHP tutorial you will come to know about integer data type of PHP, range of this data type, automatic type conversion to float, and examples will illustrate these concepts

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)
$a=int(-12)
$a=int(83)
$a=int(564)
$a=int(2147483647)
$a=float(2147483648)
Advertisement

Related Tags for PHP Integer Data Type:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 6, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com