PHP Data Types |PHP Operators
PHP Data Types
All variable can store data of different types, and different data types can do different things. PHP supports 8 primitive data types that can be categorized further 3 types.
01.Scalar Types(predefined)
02.Compound types(user-defined)
03.Special types
Scalar Types
01.boolean
Booleans are the simplest data type works like swith. It holds only two values. TRUE or FALSE, True is 1 and False is 0. It is often used with conditional statements. if the condition is correct it returns TRUE otherwise FALSE.
02.integer
Integer means numeric data with a negative or positive sign. It holds only whole numbers.
Rule for Integers:
an integer can be either positive or negative.
an integer must not contain decimal point.
integer can be decimal, octal or hexadecimal
Get Pusparasa Ayilavan’s stories in your inbox
Join Medium for free to get updates from this writer.
The range of an integer must be lie between 2,147,483,648 and 2,147,483,647 (-2³¹ to 2³¹).
03.float
A float is number with a decimal point or a number in exponential form. unlike integers.
04.string
A string is a non numeric data type. It holds letters or any alphabets, number and even special characters.
string values must be enclosed either within single quotes or in double quotes. but both are treated differently.
Compound Types
05.Array
An array is a compound data type. It can store multiple values data type in single variable.
06.object
Objects are the instances of user defined classes that can store both values and functions.
Special Types
07.Resource
Resource are not the exact data type in PHP. basically, these are to used to store some function call or references to external PHP resources. For an example A database call. it is an external resource.
08.NULL
NULL is a special data type that has only one value that has only one value. there is a convention of writing it in capital letters as it is case sensitive.










