Chapter 7th. Variable directory list website construction server script \ phpphp user manual fancylanguage.variables.html # language. variables. basics> basic fixed variable scope variable outside PHP variable base
Variable Description: in PHP, It is the name of the variable following the dollar sign. Variable names are case sensitive.
The name of the variable is the same as that of other labels in PHP. A valid variable name starts with a linestring or underline, followed by a linestring, number, or underline. As a regular expression, it would be like this: [a-zA-Z_x7f-xff] [a-zA-Z0-9_x7f-xff] *
Note: a letter is a-z, A-Z, and ASCII character 127 through 255 (0x7f-0xff ).
$ Var = "Bob"; $ Var = "Joe"; echo "$ var, $ Var"; // output "Bob, Joe" $4 site = not yet; // error; start cannot be a number $ _ 4 site = not yet; // valid; start can be an underscore $ täyte = mansikka; // valid: äis ASCII 228.
In PHP 3, variables are assigned values. In other words, when you assign an expression to a variable, the value of the original expression is copied to the target variable.
This means that assigning a variable value to another variable only changes the value of those variables without affecting other variables. For more information, see Expressions.
PHP 4 provides another way for Variable Allocation value: Reference allocation. This means that the new variable is a simple reference of the original variable (this new variable is just a "alias" or "pointing"). Changing the new variable will affect the original variable, and vice versa. This also means that no replication is executed: Therefore, the allocation speed is faster. However, such acceleration only occurs when complicated loops or large arrays and objects are allocated.
Assign a reference. You only need to add "&" before the variable (source variable. For example, the following code snippet outputs My name is Bob twice:
An Important Note: Only one specified variable can be referenced and allocated.