Variables in PHP
Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can use it repeatedly in the script.
All variables in PHP start with the $ symbol, and the variable names are case-sensitive.
The correct way to set variables in PHP is:
$var _name = value; PHP beginners tend to forget the $ symbol in front of the variable. If you do that, the variable will be invalid.
Although it is not necessary to initialize variables in PHP, this is a good habit. An uninitialized variable has a default value of its type-FALSE, 0, an empty string, or an empty array.
Copy the Code code as follows:
$var = ' PHP ';
$Var = ' tutorial net ';
echo "$var, $Var"; Output "PHP, tutorial Net"
$4site = ' not yet '; illegal change of name; start with a number
$_4site = ' not yet '; The name of the legal variable, preceded by an underscore
$i site is = ' Mansikka '; The name of the legal variable; can be in Chinese
?>
Naming rules for variables
The variable name must begin with a letter or underscore "_".
Variable names can contain only alphanumeric characters and underscores.
Variable names cannot contain spaces. If the variable name consists of multiple words, it should be delimited with an underscore (such as $my _string), or start with a capital letter (such as $myString).
The above describes the PHP tutorial PHP tutorial variable definition, including the PHP tutorial content, I hope the PHP tutorial interested in a friend helpful.