PHP has built-in Data Types which is divided into three catagories Scalar types,Compound types and Special types. PHP has total eight (8) different data types you can work with.
In PHP the boolean data type is a primitive data type they have only two possible values true and false. This is a fundamental data type and very common in computer programs.
Integer is a whole number. PHP integer is the same as the long data type in C. It is a number between -2,147,483,648 and +2,147,483,647. Integers can be specified in three different notations in PHP. Decimal, hexadecimal and octal. Octal values are preceded by 0, hexadecimal by 0x.
Rules for integers
This will produce following result
Float may contain any decimal number or a number in exponential form.Floating point numbers in PHP can be larger than integers. PHP recognizes two types of floating point numbers. The first is a simple numeric literal with a decimal point and second is a floating-point number written in scientific notation.
This will produce following result
String is a series of single characters such as "Hello PHP". Most of working with Web pages is about working with strings. In PHP a string must be delimited by one of four syntaxes: single quotes, double quotes, heredocs, and nowdocs.
This will produce following result
In simple word array is complex data type which hold collection of related data elements.Each of the elements can be accessed by an index.
This will produce following result
In simple word object are instances of class definitions. Objects are user defined data types normaly used to define properties/attributes of object. First we need to declear a class of object that can contain properties and methods.
This will produce following result
Resources are special data types. They hold a reference to an external resource (such as database connections).
NULL is a special type that only have one possible value and that's null. This type is also treated as a language constant in PHP and is case-insensitive. PHP considers all undefined variables to be of type NULL.
This will produce following result