Data Types Available in PHP

Share Now

8 data types available

  1. Integer
  2. Float/Double
  3. Boolean
  4. String
  5. Array
  6. Object
  7. Null
  8. Resource


Integers: Integers are whole numbers, without a decimal point (…, -2, -1, 0, 1, 2, …)

Floating Point Numbers or Doubles: Floating point numbers (also known as “floats”, “doubles”, or “real numbers”) are decimal or fractional numbers. example: $a = 1.234; $b = 10.2e3;

Strings: Strings are sequences of characters. The simplest way to specify a string is to enclose it in single quotes (e.g. ‘Hello world!’), however, you can also use double quotes (“Hello world!”).

Booleans: Booleans are like a switch it has only two possible values either 1 (true) or 0 (false). example:  $show_val =trye;

Arrays: An array is a variable that can hold more than one value at a time.

Objects: An object is a data type that not only allows storing data but also information on, how to process that data. An object is a specific instance of a class that serves as templates for objects. Objects are created based on this template via the new keyword.

Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert