PHP Variables: Variables are "containers" for storing information. PHP variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carName.
Rules for PHP variable names:
- Variables in PHP starts with a $ sign, followed by the name of the variable
- The variable name must begin with a letter or the underscore character
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- A variable name should not contain spaces and Variable names are case sensitive (y and Y are two different variables)
PHP Variable Scope: The scope of a variable is the
portion of the script in which the variable can be referenced. PHP has four
different variable scopes:
- Local
- Global
- Static
- Parameter