Variables in php - you will know variables after studying in junior high school
When you were in junior high school. Teachers often teach you this.
Excuse me, Li Lei and Han Meimei, if:
x = 5 y = 6
Then what is x + y equal to? Everyone will answer without hesitation. x + y equals 11.
Next let’s look at the following junior high school mathematics knowledge. What is the result of x + y?
x = 5 y = 6 x = 8
I guess everyone will answer without hesitation: the result of x + y is 14.
This is a variable!
Several characteristics of variables:
1.x = 5 Assign the value 5 on the right to x on the left
2. The second paragraph x = 8, and finally x + The result of y is equal to 14, indicating that x can be reassigned in the operation (execution) from top to bottom.
The same is true for our variables in PHP. But there are several characteristics:
1. It must start with $. For example, the variable , Chinese, _ is not a special symbol
5. Variable names must be meaningful (do not write variable names such as xxx, aaa, ccc)
Error examples:
Error: variable starts with a number
Error: special characters in variable, ChineseError: variable naming makes no sense aaaeasy to count Wrong, it has no meaning
Error: Variables are strictly case-sensitive. $dog and $Dog are variables of the PHP Academy. Try changing the value of $dog to 8. As a result, D is written in uppercase.
Correct example:
Correct: A variable cannot start with a number, but a number can be sandwiched between and at the end of the variable name
Correct: Variables cannot have special symbols, but _ (underscore is not a special symbol)Note: You will find that the code is executed from top to bottom.
$ is called the dollar sign, and the English word is: dollar. PHP variables must start with a dollar sign. It shows that there is a "money" way to engage in PHP.
dollar
Pronunciation: ['dɒlə(r)]Explanation: US dollar