PHP: Types of variables

This entry is part 5 of 54 in the series PHP Tutorial

Just like any other programming languages, we can have different types of variables.

$var1 = 0;                          // Integer
$var2 = 3.14;                       // Float
$var3 = 'I am a string';             // String
$var4 = true;                       // Boolean
$arrayVar = array(250, 300, 325, 475);  // Array
  • Integer – Whole numbers. These can be either positive or negative.
  • Float – Numbers with decimal places. These can also be either positive or negative.
  • String – A mixture of letters, numbers, and symbols. Strings are surrounded by quotes.
  • Boolean – One of two values: true or false. The value must not have any quotes as this would turn it into a string.
  • Array – A multi-level storage type, similar to a table.
Series Navigation<< PHP: Variables
PHP: Variables are case sensitive >>