Variables can store different types of data. A data type is a set of values and the allowable operations on those values.

Scalar types

  • boolean - Represents true or false. Ex: $logged_in = true.
  • integer -  Numbers without decimal points. Ex: $age = 25.
  • float - Numbers with decimal points. Ex: $price = 10.99.
  • string - Sequence of characters. Ex: $name = “John”.

Compound types

  • array - It Represents a collection of values and indexed by keys. Ex: $fruits = array("apple", "banana", "orange");
  • object -  Represents an instance of a class
<?php 
class Person {
    public $name;
    public $age;
}
$person = new Person();
$person->name = "John";
$person->age = 25;
?>

Special types

  • resources
  • NULL -  Represents a variable with no value assigned. Ex: $var_name = null;