PHP - Introduction Using Variables


Variables are a fundamental part of any programming language.

A variable is a container that holds a certain value.

Naming Variables

A variable consists of two parts: the variable's name and the variable's value.

PHP has certain rules you must follow when naming your variables:

  • Variable names begin with a dollar sign $
  • The first character after the dollar sign must be a letter or an underscore
  • The remaining characters in the name may be letters, numbers, or underscores without a fixed limit

Variable names are case - sensitive.

$Variable and $variable are two distinct variables.

Here are some examples of PHP variable names:


Related Topic