Have an account? Sign in
Login  Register  Facebook
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
[Edit] Naming Variables
A variable consists of two parts: the variable ’ s name and the variable ’ s value. Because you ’ ll be using variables in your code frequently, it ’ s best to give your variables names you can understand and remember. Like other programming languages, 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), so it ’ s worth sticking to one variable naming method — for example, always using lowercase — to avoid mistakes. It ’ s also worth pointing out that variable names longer than 30 characters are somewhat impractical. Here are some examples of PHP variable names:
$my_first_variable
$anotherVariable
$x
$_123
September 15, 2011