In this tutorials, I am going to give you the list of php data types. PHP data types are divided in about 8 categories. Here is the list..,

PHP data types :

  • Strings
  • Boolean
  • Float
  • Integer
  • Array
  • NULL
  • Resource

PHP String :

String is a stream of characters. They may be expressed in single or double quotes.

$v1="<p>Strings are expressed within double quotes</p>";
$v2='<p>Or single quotes as in this here</p>';

echo "<center><h1>PHP Strings</h1></center>";
echo $v1;
echo $v2;

Output :

php data types 1

PHP Integer :

These are digits that span across the number line without decimals. PHP allows inputs of any digits between -2,147,483,648 and 2,147,483,647.

Integers must:

  1. Have at least a digit
  2. Have no decimals
  3. Be positive or negative
  4. Be stated in decimal, hexadecimal, or octal formats

The var_dump() function is used to display structured information (type and value) about one or more variables.
Output :

php data types 2

PHP Float :

This statement parses numbers with decimal points and those with exponents.

$b = 3.14159;



PHP Boolean

It is a variable that is often represented as bool. It is used in two states, which are to show whether the situation or outcome is TRUE or FALSE. It is used in conditional testing.

PHP Array

Arrays are variables that are used to store one or more (many) values. In the following example, the var_dump reveals an array.

$variables = array("Arrays","Boolean","integers");

Output :

array(3) { [0]=> string(6) "Arrays" [1]=> string(7) "Boolean" [2]=> string(8) "integers" }

PHP Object

It is a data type that stores instructions on how to process data. PHP objects must me declared explicitly, first under a class, which is a structure containing methods and properties.

class phones {
function phones() {
$this->company = "Apple";

// create an object
$model = new phones();

// show object properties
echo $model->company;

Output :


PHP Null :

This data type returns only one value, which is NULL. It is returned if no value is assigned.

Values that are instantiated without value assignment are automatically given the NULL value. This data type may also be used to empty variables.

$x = "Hello world!";
$x = null;

PHP Resource

It is a resource type that stores references to functions and external resources.

Happy Learning 🙂