• Have Any Question?
  • contact@eitworld.com

PHP Datatypes

There are different data types used in php. A function is also available to see the data type of a variable. var_dump() function returns the data type and the value of a variable.



An integer is a simple number without decimal. It may be either positive or negative and can be used in three formats-

  • Decimal- 2, 4, -58, 10
  • Octal- They are preceded by 0. Like 065, 034, 067
  • Hexadecimal- They are preceded by 0x. Like 0x45, 0x89, 0x765.



They are real numbers containing decimal or exponential terms. They can be used in two formats-

  • With decimal point- 100.45, 43.56, -0.5678
  • In exponential form- 34E56, 6E-8



String is a group of characters or sequence of characters enclosed by single or double quotes. Like “This is a string”, ‘Hello World’, “Hello”

$var1= “A string”;$var2= ‘A string’;



This type of variables can have only two values- true or false. They are generally used in conditions.



In php, an array can store multiple values of various datatypes. array() function is used to create an array.


$var=array("value1", "value2", "value3");

print_r() function is used to display complete array at once.




  • In the output, the numbers are called the index. Each value in an array has different index and using that index you can access the value at that index. For e.g.
    • echo $countries[0] will display India
    • echo $countries[2] will display China
  • More about arrays will be described in a separate chapter PHP-Arrays.


  • This type of variable can have only one value null. This is not really any value. The mean of null is that there is no value. It can be used to compare if a variable has some value or not.


Real Time Web Analytics