Variable can store data of different types, and different types can do different things.
PHP support following data types:
A String is a sequence of character like “Hello Microtech!!”;
A String can be any text inside quotes.You can use single or double quotes:
An Integer is a whole number (without decimal).It is a number between -2,147483,648 and +2,147,483,647.
Rules for Integers:
- An Integer must haveat least one digit (0-9).
- An Integer can not contain comma or blank
- An Integer must have not decimal point
- An Integer can either positive or negative
- Integer can be spacified in three format :decimal (10-based), hexadecimal (16-based), or octal (8-based)
A float (floating point number) is a number with a decimal point or a number in exponential form.
A Boolean represent two possible states: TRUE or FALSE.
Booleans are often used in conditional testing. You will learn more about conditional testing in a later chapter of this tutorial.
An Array store multiple value on single variable.
[sam id=”4″ codes=”true”]
An object is data type which store data and information on how to process that data.
In PHP Object must be explicitly declared.
First we must declare a class of object. For this, we use the class keyword. A class is a structure that can contain properties and methods:
$x = “Hello Microtech!”;
$y = ‘Hello Microtech!’;
//The PHP var_dump() function returns the data type and value