What are the different data types in PHP?

The PHP manual lists ten primitive data types in three groups.

GroupTypeExample
Scalarstring“Hello PHP!”
Scalarinteger2567
Scalarfloat (double)1.5 or 134.153
Scalarbooleantrue or false
Compoundarray[1, 2, 3]
CompoundobjectAn instance of a class
CompoundcallableA function that can be called
CompounditerableAn array or an object that can be looped
SpecialNULLA variable with no value
SpecialresourceA reference to an outside thing, like an open file

In PHP you do not write the type when you create a variable. PHP picks it from the value. You can check it with var_dump() or gettype(). Learn all of them with examples in PHP Data Types.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What are the different data types in PHP?