Creating variables
PHP does not have a command to create a variable, it is created when the first assignment is made, and is automatically converted to the correct data type.
PHP Naming conventions:
The variable starts with the $ sign, followed by the name of the variable.
The variable name must begin with an underscore and a letter.
Variable names can contain only alphabetic characters and underscores. (A-Z, 0-9, and _)
Variable names are case-sensitive ($S and $s are not the same variable)
PHP variable Scope
Local (partial)
Global (globally)
Static (statically)
LOCAL Scope and global scope
Variables declared outside the function have Global scope and can only be accessed outside of the function.
Variables declared inside a function have a local scope and can only be accessed inside the function.
Give one of the two examples to improve your understanding.
";//Change the echo $b; The value is 2--there is no change, or what a person should do. echo "
"; } Test (); echo $a; Value is 1, unchanged---time flow, the goddess was Ko Fu handsome abandoned or a person echo "
"; echo $b; Variable b in output function outside function, output is empty--goddess was abandoned back to find Loser,loser said when I was stupid, the baby in the belly is not mine, so the output is empty. echo "
"; echo "The line above is empty!" "?>
Global keywords
In the case of the above example, it is to make loser (local variable B) The Magic Weapon of the goddess (global variable a)--to become a high-rich handsome
Used both to access global variables within a function
"; echo $b; A value of 2--output variable b outside of the function is not empty--both now Gaofu and goddess of how to blind, how blind to engage in?>
Static keyword
In general, all local variables are deleted when the function is finished---both high and handsome, the goddess will lose
However, sometimes I need not delete a local variable----also do not rule out happy life together
You can get rid of the static to realize its role ...