PHP Tutorial

A web server programming language.

PHP Variables

PHP Variables

Variables are "containers" for storing information. In PHP, a variable starts with the $ sign, followed by the name of the variable.

Rules for PHP variables:

  • Starts with the $ sign
  • Must start with a letter or the underscore character
  • Cannot start with a number
  • Can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variables are case-sensitive ($age and $AGE are different variables)

Unlike other languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics