PHP Data Types

Online resources

Key concepts to understand

  • Variables

    • Variable naming rules
      • start with $
      • contain letters, numbers, underscores; no spaces
      • are case-sensitive
    • How to set and get values
  • Strings

    • Single-quoted, double-quoted
    • String concatenation
    • String interpolation / variable parsing PHP.net
  • Integers

    • Difference between integers and floating point numbers
    • Arithmetic operators: +, -, *, /, ()
  • Floating point numbers

    • Difference between integers and floating point numbers
  • Arrays

    • Defining with array() or []
    • Comma-delimited
    • Zero-indexed
    • Always maintained in the same order
    • How to set and retrieve values
  • Associative arrays

    • Syntax and key/value pairs
    • Array keys must be unique
    • How to set and retrieve values
  • Booleans

    • true or false
  • Null

    • used to indicate nothing or "no value set"
    • different than 0, "", or false
    • explain how to use isset() and empty()
    • considered empty: null, [], "", false, 0, 0.0, "0"
      • using empty() incorrectly is a common source of PHP bugs
  • Constants

    • How to define them
Fork me on GitHub