PHP

In PHP, certain rules must be followed when assigning names to your variables.

  • Variables are written as $var_name, where var_name is the name of the variable. The name can contain only Latin characters (English uppercase or lowercase characters), numbers, and the underscore character ( _ ). Examples of variable names are $firstName, $last_name1, and $age.
  • Variable names are case sensitive, which means there is a distinct difference between uppercase and lowercase characters. For example, $myVAR, $myvar, $MYVAR, and $MyVar are actually four different variables.
  • No space characters are allowed. If a variable is described by more than one word, you can use the underscore character ( _ ) between the words. For example, the variable name $student age is wrong. Instead, you might use $student_age, or even $studentAge.
  • A valid variable name can start with a letter or an underscore. Numbers are allowed, but they cannot be used at the beginning of the variable name. For example the variable name $1student_name is not properly written. Instead, you might use something like $student_name1 or $student1_name.
  • A variable name is usually chosen in a way that describes the meaning and the role of its contained data. For example, a variable that holds a temperature value might be named $temperature, $temp, or even $t.

Java

In Java, certain rules must be followed when assigning names to your variables.

  • The name of a variable can contain only Latin characters (English uppercase or lowercase characters), numbers, the dollar sign ( $ ), and the underscore character ( _ ). Examples of variable names are firstName, last_name1, and age.
  • Variable names are case sensitive, which means there is a distinct difference between uppercase and lowercase characters. For example, myVAR, myvar, MYVAR, and MyVar are actually four different variables.
  • No space characters are allowed. If a variable is described by more than one word, you can use the underscore character ( _ ) between the words. For example, the variable name student age is wrong. Instead, you might use student_age, or even studentAge.
  • A valid variable name can start with a letter, a dollar sign, or an underscore. Numbers are allowed, but they cannot be used at the beginning of the variable name. For example the variable name 1student_name is not properly written. Instead, you might use something like student_name1 or student1_name.
  • A variable name is usually chosen in a way that describes the meaning and the role of its contained data. For example, a variable that holds a temperature value might be named temperature, temp, or even t.

C++, C#, Python

In C++, C#, and Python, certain rules must be followed when assigning names to your variables.

  • The name of a variable can contain only Latin characters (English uppercase or lowercase characters), numbers, and the underscore character ( _ ). Examples of variable names are firstName, last_name1, and age.
  • Variable names are case sensitive, which means there is a distinct difference between uppercase and lowercase characters. For example, myVAR, myvar, MYVAR, and MyVar are actually four different variables.
  • No space characters are allowed. If a variable is described by more than one word, you can use the underscore character ( _ ) between the words. For example, the variable name student age is wrong. Instead, you might use student_age, or even studentAge.
  • A valid variable name can start with a letter, or an underscore. Numbers are allowed, but they cannot be used at the beginning of the variable name. For example the variable name 1student_name is not properly written. Instead, you might use something like student_name1 or student1_name.
  • A variable name is usually chosen in a way that describes the meaning and the role of its contained data. For example, a variable that holds a temperature value might be named temperature, temp, or even t.

Notice: Even though Python does not support constants as do other computer languages (such as C#, or C++), you can use a variable instead. However, it is advisable to use only uppercase letters. This helps you to visually distinguish those variables that are used as constants  from the actual variables.

Visual Basic

In Visual Basic, certain rules must be followed when assigning names to your variables.

  • The name of a variable can contain only Latin characters (English uppercase or lowercase characters), numbers, and the underscore character ( _ ). Examples of variable names are firstName, last_name1, and age.
  • Variable names are not case sensitive, which means there is no difference between uppercase and lowercase characters. For example, the myVAR, myvar, MYVAR, and MyVar names are actually referring to the same variable.
  • No space characters are allowed. If a variable is described by more than one word, you can use the underscore character ( _ ) between the words. For example, the variable name student age is wrong. Instead, you might use student_age, or even studentAge.
  • A valid variable name can start with a letter, or an underscore. Numbers are allowed, but they cannot be used at the beginning of the variable name. For example the variable name 1student_name is not properly written. Instead, you might use something like student_name1 or student1_name.
  • A variable name is usually chosen in a way that describes the meaning and the role of its contained data. For example, a variable that holds a temperature value might be named temperature, temp, or even t.