CopyPastehas never been so tasty!

Assign integer using different syntaxes in PHP

by anonymous

  • 0
  • 0
  • 0

orignal source:

Integer Data Type:


In PHP integer is single-value type. Integers are whole numbers. Its range varies according to your platform. But you can use any number from -2,147,483,648 to +2,147,483,647. Integer can be written in decimal, octal and hexadecimal. In decimal we can represent integer without zero.


For example:


1998 (Decimal)



In octal integer can be represented with a leading 0 and a sequence of digits from 0 to 7.


For example:


0755 (Octal)



In hexadecimal integer can be represented with 0-9 and alphabets A-F. 

For example:





In php we just assign a value to a variable and on the basis of that value data type is confirmed.



Assigning integer values using different syntaxes in PHP:



We can assign integer values to a variable. In php we use different syntaxes for assigning integer values.







$a = 1234;                   //as a decimal number

$a = -123;                  //as  a negative number

$a = 0123;               //as a octal number (equivalent to 83 decimal)

$a = 0x12;             //as a hexadecimal number (equivalent to 18 decimal)





Above is the simple code to assign integer values using different syntaxes in PHP.


This simple article tells that how assign integer values using different syntaxes in PHP.

Add A Comment: