PHP provides four scalar types namely Boolean, integer, double and string and two compound types namely array and object and two special types namely resource and NULL.
PHP has a single integer type, named integer. This type is same as long type in C. The size of an integer type is generally the size of word in the machine. In most of the machines that size will be 32 bits.
PHP’s double type corresponds to the double type in C and its successors. Double literals can contain a decimal point, an exponent or both. An exponent is represented using E or e followed by a signed integer literal. Digits before and after the decimal point are optional. So, both .12 and 12. are valid double literals.
String is a collection of characters. There is no special type for characters in PHP. A character is considered as a string with length 1. String literals are represented with single quotes or double quotes. In a string literal enclosed in single quotes, escape sequences and variables are not recognized and no substitutions occurs. Such substitution is known as interpolation. In string literals enclosed in double quotes, escape sequence and variables are recognized and corresponding action is taken.
The only two possible values for a Boolean type are TRUE and FALSE both of which are case-insensitive. Integer value 0 is equal to Boolean FALSE and anything other than 0 is equal to TRUE. An empty string and string “0” are equal to Boolean FALSE and remaining other strings are equal to TRUE. Only double value equal to Boolean FALSE is 0.0.
A video tutorial on data types in PHP: