PHP variables must be preceded by a $ sign, and are interpreted weakly typed languages that do not need to define the type of the variable value at the time of definition.
$str = "This is a variable";
1. When the output can be used to stitch the string method
such as: Echo "abcdef". $str; The connection symbol for the character car variable is "." Differs from the "+" in other languages. Each code is ";" End.
Output: ABCEDF This is a variable.
2. Direct double Quote quote output
Because PHP's variable definition is very special, with the $ sign in front, even if enclosed in double quotes, the interpreter automatically interprets it as a variable.
such as: echo "ABCEEF$STR"; Enclose all double quotes to ";" End.
Output: abcdef This is a variable.
It is important to note that the interpreter must be enclosed in double quotation marks to explain the variables. If the interpreter is not interpreted in single quotation marks. It's best to put the variables outside the double quotes when you use them.
such as: Echo ' abcdef$str ';
Output: Abcdef$str
The direct output of the variable name does not explain the value of the variable.
Another thing to note about variables in PHP is that variable names are sensitive to letter case, $STR and $STR will be interpreted as two different variables. Just as opposed to the function definition in PHP, the function definition is not case-sensitive.
Variable names can include letters, numbers, and _ (underscores) but cannot start with a number.
PHP variables and arrays do not need to be pre-defined and initialized, and can be defined directly when used.
such as: $person [0]= "Zhangsan"; $person [1]= "Lisi"; $person [2]= "Wangwu";
Print_r ($person);
Output: Array ([0] = Zhangsan [1] = lisi [2] = Wangwu)
PHP variable definition and usage