There are 8 primary data types in PHP which are used to construct the variables. They are:
- Integers: Integers are whole numbers without a floating point. Ex: 1253.
- Doubles: Doubles are floating-point numbers. Ex: 7.876
- Booleans: It represents two logical states- true or false.
- NULL: NULL is a special type that only has one value, NULL. When no value is assigned to a variable, it can be assigned with NULL.
- Arrays: An array is a named and ordered collection of similar types of data. Ex: $colours = array("red", "yellow", "blue");
- Strings: Strings are a sequence of characters. Ex: “Hello InterviewBit!”
- Resources: Resources are special variables that consist of references to resources external to PHP(such as database connections).
- Objects: An instance of classes containing data and functions. Ex: $mango = new Fruit();