> Data types in PHP ~ Online tutorial

Data types in PHP

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.

Data Type Description Example
Integer An integer is a plain-vanilla

number like 75, -95, 2000,

or 1.
$age = 99;
Boolean The simplest variable type

in PHP, a Boolean variable

simply specifies a true or

false value
$auth = true;
Floating-point A floating-point number

is typically a fractional

number such as 12.5

or 3.149391239129.

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

'abracadabra'. String

values may be enclosed in

either double quotes ("") or

single quotes ('').
$name = 'Harry';
In many languages, it’s essential to specify the variable type before using it; for

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.

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
Powered By: BloggerYard.Com