PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




Integer data type in PHP


Tutorials »Php »

Topic

How to define a Integer variable and assign value?



Explanation

The integer data type is used to specify a numeric value without a fractional component.

The range of integers in PHP is equivalent to the range of the long data type in C. On 32-bit platforms, integer values can range from -2,147,483,648 to +2,147,483,647. When you are declaring integer variable, you can declare as given below

integer $variable;

where integer denotes the type of the variable.

You can also declare variable without datatype, in such case PHP will try to determine type of variable based on the value hold by that variable. Below I have declared a variable without its type.

$variable =10;

Here the variable hold the integer value so it is of type integer.

If you want to get a type of a variable, you can use gettype() function.
Example:

print gettype($variable);

Above code will print type integer because integer(whole number) value is assigned to that variable. If you specify a number beyond the limits of the integer type then PHP automatically converts larger values to floating point numbers.





Other Links

web hosting