PHP Tutorial variable definition. Variable variables in PHP are used to store values, such as numbers, text strings, or arrays. Once a variable is set, we can reuse it in the script. All the variables in PHP
Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can reuse it in the script.
All variables in PHP start with the $ symbol, and the variable names are case sensitive.
The correct method for setting variables in PHP is:
$ Var_name = value; PHP users often forget the $ symbol before the variable. In this case, the variable will be invalid.
Although variables do not need to be initialized in PHP, this is a good habit. Uninitialized variables have default values of their type-FALSE, zero, null string, or empty array.
The code is as follows:
$ Var = 'php ';
$ Var = 'tutorial net ';
Echo "$ var, $ Var"; // output "PHP, tutorial network"
$4 site = 'not Yun'; // The name of an invalid change. it must start with a number.
$ _ 4 site = 'not Yun'; // valid variable name; starting with an underscore
$ I site is = 'mansikka '; // valid variable name; Chinese
?>
Variable naming rules
The variable name must start with a letter or underscore.
Variable names can only contain letters, numbers, and underscores.
Variable names cannot contain spaces. If the variable name is composed of multiple words, it should be separated by underscores (for example, $ my_string) or begin with an uppercase letter (for example, $ myString ).
Variable variables in the http://www.bkjia.com/PHPjc/320761.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320761.htmlTechArticlePHP are used to store values, such as numbers, text strings, or arrays. Once a variable is set, we can reuse it in the script. All variables in PHP...