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<?php
3 = 345;
?>
Error: special characters in variable, Chinese<?php
//$a*d = 345;
//$中国 = 123;
?>
Error: variable naming makes no sense aaaeasy to count Wrong, it has no meaning
<?php $aaaaaaa = 345; ?>
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.
<?php $dog = 5; //重新修改$dog的值,将$dog改为8 $Dog = 8; ?>
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<?php
$iphone6 = 5880;
$iphone6plus = 6088;
?>
Correct: Variables cannot have special symbols, but _ (underscore is not a special symbol)<?php
$_cup = 123;
?>
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