• Home
  • PHP Data Types

PHP Data Types

PHP supports 8 data types:

  1. Integer: A whole number, either positive or negative.
  2. Float: A number with a decimal point.
  3. String: A sequence of characters.
  4. Boolean: A true or false value.
  5. Array: A collection of values.
  6. Object: An instance of a class.
  7. NULL: A special type that represents a variable with no value.
  8. Resource: A special type that represents a reference to an external resource, such as a database connection.

PHP is a loosely typed language, which means that the data type of a variable is not explicitly declared. Instead, it is determined by the value that is assigned to the variable. For example, if a string value is assigned to a variable, it becomes a string type. If an integer value is then assigned to the same variable, it becomes an integer type.