PHP Data Types

PHP Data Types


PHP data types are used to hold different types of data or values. 
PHP supports the following data types:
  • String
  • Integer
  • Float
  • Boolean
  • Null

 

String data type: String is a collection of characters. The string can be enclosed in single or double quotes.

Example:

Output: Web Designing

 

  • The function var_dump() returns the data types and value.
For example:

 Output: string (13) "Web Designing"

 

Integer data type: Integer is a positive or negative number without decimal value. Integer is of only number, without comma and decimal value.

Example:

Output:  int (258)

            258 

 

Float data type: The numeric value, which consists of decimal value called as floating value.

Example:

Output: float (35.25)

 

Boolean data type: Boolean is a data type which represents true or false.

For example:

Output: bool(true) bool(false)

Null data type:  Null represents no value; this is a special data type which don’t assign any value to variable.

 For example:

Output: Null