Php variables must be preceded by the $ symbol and are interpreted as weak type languages. You do not need to define the type of variable values. $ str this is a variable; 1. you can concatenate strings for output, for example, echoabcdef. $ str; The Connection Symbol of the character vehicle variable is. it is different from other languages. each line of code ends. output: abced
Php variables must be preceded by the $ symbol and are interpreted as weak type languages. You do not need to define the type of variable values. $ str = "this is a variable"; 1. you can concatenate strings for output, for example, echo "abcdef ". $ str; The Connection Symbol of the character car variable is ". "is different from" + "in other languages. each code sentence ends. output: abced
Php variables must be preceded by the $ symbol and are interpreted as weak type languages. You do not need to define the type of variable values.
$ Str = "this is a variable ";
1. concatenate strings for output.
For example, echo "abcdef". $ str; the connected symbol of the character vehicle variable is "." different from other languages "+". Each sentence of code ends.
Output: abcedf. This is a variable.
2. Direct Double quotation marks reference output
Because the variable definition in php is very special, there is a $ symbol in front. Even if it is caused by double quotation marks, the interpreter will automatically interpret it as a variable.
For example, echo "abceef $ str"; enclose all double quotation marks and end.
Output: abcdef. This is a variable.
Note that the variables must be enclosed in double quotation marks before the interpreter can interpret the variables. If you enclose the variables in single quotation marks, the interpreter will not explain them. It is best to put the variables out of double quotation marks when you only use them.
For example, echo 'abcdef $ str ';
Output: abcdef $ str
Directly output the variable name without interpreting the variable value.
In php, the variable name is case sensitive. $ str and $ Str are interpreted as two different variables. this is exactly the opposite of the Function Definition in php. The function definition is case insensitive.
The variable name can contain letters, numbers, and underscores (_), but cannot start with a number.
Php variables and arrays do not need to be pre-defined or initialized. You can directly define them when using them.
For example, $ person [0] = "zhangsan"; $ person [1] = "lisi"; $ person [2] = "wangwu ";
Print_r ($ person );
Output: Array ([0] => zhangsan [1] => lisi [2] => wangwu)