Understanding Simple Data Types
Every language has different types of variables—and PHP has no shortage of choices.
The language supports a wide variety of data types, including simple numeric,
character, string, and Boolean types, and more complex arrays and objects.
|Integer||An integer is a plain-vanilla
number like 75, -95, 2000,
|$age = 99;|
|Boolean||The simplest variable type
in PHP, a Boolean variable
simply specifies a true or
|$auth = true;|
|Floating-point||A floating-point number
is typically a fractional
number such as 12.5
Floating point numbers may
be specified using either
decimal or scientific notation.
|$temperature = 56.89;|
|String||A string is a sequence of
characters, like 'hello' or
values may be enclosed in
either double quotes ("") or
single quotes ('').
|$name = 'Harry';|
example, a variable may need to be specified as type integer or type array.
Give PHP credit for a little intelligence, though—the language can automagically
determine variable type by the context in which it is being used.