It is used to express different data types that are associated with the variables or function return's type.
PHP variables are used to hold different data types such as Integer, Floating point number or Float, String, Booleans, Array, Object, resource, and NULL. These are mainly classified into three categories:
There is 4 scalar data type in PHP and it contains a single value.
It can hold multiple data and it is categorized into two parts.
There are 2 special data types in PHP.
PHP integers are basically the whole numbers without decimal point such as 1,2,3,-1,-2,0, etc.
Floating point numbers ("floats", "doubles" or "real numbers") are numbers with a decimal point or a number in exponential form.
A string is a finite sequence of characters that is enclosed with single or double-quotes. The string characters might be letters, numbers, special characters, symbols, etc.
There are four ways to represent a string. These are:
PHP array is a variable that holds multiple values in a single variable. There are two ways to represent array:
PHP object is basically is an instance of a user-defined class that has the ability to access instance variables and functions. Every object is completely independent of the other because they have their own properties and methods.
PHP NULL value is a special variable that has no value. It identifies whether a variable is empty or not. We can use the
is_null() function to check any value if it is NULL.
Understand The Basic Differences:
When a user has created a variable like
$var then a
null value is automatically assigned to it. Therefore, keep in mind that
$var2="" is not same. Here
$var1 represents null value while
$var2 represent empty value.
It is a special variable that holds the reference of other external resources. Basically, it belongs to the database function.
gettype() – data type getter returns given variables data types.
var_dump() – This function is used to get the data type of an expression.
is_ – There are several variable functions like is_array(), is_null() and etc., to check a variable with respect to specific data type.
settype() – This is the data type setter, used in PHP type conversion.