Understanding PHP data type

What are Data Types in PHP ?

A data type  is a classification identifying one of various types of data, such as real, integer or Boolean, that determines the possible values for that type, the operations that can be done on values of that type, the meaning of the data, and the way values of that type can be stored in other words A particular kind of data item, as defined by the values it can take, the programming language used, or the operations that can be performed on it. Likewise all other language PHP also have data types.

Data Type in PHP.

  1. Data type in PHP are of intrinsic. It means no explicit declaration is need for the variable in PHP .
  2. Variable name must have a prefix \”$\”(dollar sign ) .
  3. Variable name must follow rules for an identifier and should not start with Number.
  4. Use \’\\\’as prefix to variable name to skip it from being interpolated. \’\\\’ is called Escape sequence.
  5. To know the Type of data type  gettype function can be used .
    eg. gettype(variable); /// it returns the data type of variable
  6. We Can have double and single quotes  string in PHP.
  7. Single quote string does not contain interpolation
  8. PHP support following type of Data Types
    • String
    • Integer
    • Float (floating point numbers – also called double)
    • Boolean
    • Array
    • Object
    • NULL
    • Resource
Scroll to Top