PHP Data Types

PHP datatype specifies which type of data a variable can store.

There are following data types of PHP:

  • String
  • Integer
  • Float
  • Boolean
  • Array

1. PHP Strings

This is sequence of characters which can be put in whether double quotes or single quotes.

Example:

Result:

2 PHP Integers

Integers are whole numbers in which there would be no decimal.

It should have at least numeric digit, do not include any comma or blank space, can be positive or negative but not any decimal part and it can only be expressed in decimal, hexadecimal and octal decimal .
Example:

Result:

3 PHP float

This can be presented in decimal format or in exponential form.

In PHP real values are considered as php double, or float or real data type.
Example:

Result:

4 PHP Boolean

boolean php have two optional with them one is true and another is false.

Syntax:
$a=TRUE;
$B=FALSE;

Result

5 PHP Array

It can easily store multiple values in single variable.

Example: Print integer array in PHP using for loop.

Result:

Example: Print String array in PHP using foreach loop.

Output