Naming rules for php variables
PHP variable names cannot be randomly chosen and must follow the naming rules for php variables, as follows: (Recommended learning:PHP video tutorial)
a. It must start with a dollar sign ($), such as: $a, $b;
b, dollar sign ( The first letter after $) can only be an underscore "_" or a letter, not a number (for example: $3a is illegal);
c, the part after the dollar sign ($) can only be It consists of letters, underscores (_) and numbers;
Note:
php variable names are case-sensitive, for example: $name and $Name are two Different variables;
The naming of php variables is generally based on the meaning of the name, and is named using English words. If it consists of more than one word, capitalize the first letter of each word except the first.
Declaration of php variables
The declaration of php variables is very simple. Since php is a weak language, there is no need to specify the variable type when declaring variables. Its PHP variables can be used without declaration, and are automatically declared when used.
As shown below:
Calculate the sum of variable $number1 and variable $number2
The above is the detailed content of What does a php variable name consist of?. For more information, please follow other related articles on the PHP Chinese website!