What are PHP variables, and how to set PHP variables? In this chapter, let the "newbie" take you to understand PHP for the first time, and how to become a PHP master little by little. Let's chat together
##What are variables?
Variables are "containers" used to store information; The code is as follows:Just Like algebra in mathematics:
x=3y=7
z=x y
z=x y, so we can get the result to be 10;
PHP variable rules:
1. Variables start with the $ symbol, followed by the name of the variable2. The variable name must start with a letter or underscore character
3. The variable name can only contain alphanumeric characters and underscores (A-z, 0-9 and _) 4. Variable names cannot contain spaces 5. Variable names are case-sensitive ($yand
$Yare two different variables)
Create PHP variables
For PHP, there is no command to declare variables. The variable is created when it is assigned for the first time; The code is as follows;Supplement:
PHP variable scope
《PHP video tutorial》
The above is the detailed content of How to add variables in PHP? (Source code attached). For more information, please follow other related articles on the PHP Chinese website!