PHP Data Types


Variable can store data of different types, and different types can do different things.

PHP support following data types:

  • String
  • Integer
  • Float(double)
  • Array
  • Boolean
  • Object
  • Null
  • Resource

PHP String

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:

PHP Integer

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)

PHP Float

A float (floating point number) is a number with a decimal point or a number in exponential form.


PHP Boolean

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.


PHP Array

An Array store multiple value on single variable.


[sam id=”4″ codes=”true”]


PHP Object

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:

[message_box color=”yellow”]


$x = “Hello Microtech!”;
$y = ‘Hello Microtech!’;

echo $x;
echo “<br>”;
echo $y;
//The PHP var_dump() function returns the data type and value





Previous articlePHP Variable Scopes
Next articlePHP Strings

Leave a Reply

Be the First to Comment!

Notify of