Google News
logo
PHP - Interview Questions
What are the different types of PHP variables ?
PHP has a total of eight data types which we use to construct our variables  :

Arrays : are named and indexed collections of other values. An array stores multiple values in one single variable.

Booleans : Booleans are the easiest type. A boolean expresses a truth value. It can be either TRUE or FALSE.

Floating - Floating point numbers ("floats", "doubles" or "real numbers") 

Integers : An integer data type is a number of -2, -1, 0, 1, 2, ... Integers can be specified in decimal (10-based), hexadecimal (16-based) or octal (8-based) 

notation, optionally preceded by a sign (- or +).

Objects : To initialize an object, you use the new statement to instantiate the object to a variable.

Resources : A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.

Doubles : are floating-point numbers, like 3.14159 or 49.1.

Strings  : A string is sequence(series) of characters. where every character is the same as a byte.

A string literal can be specified in three different ways.

single quoted : 'Hello world!'
double quoted : "Hello world!"
heredoc syntax : strings is by using heredoc syntax ("<<<").

NULL : The NULL is a special data type. NULL value represents that a variable has no value. NULL is the only possible value of type NULL.
Advertisement