The variable environment for php development has been set up, so we can enjoy coding below. there are still a lot of variables used in php. The following describes some rules for naming php variables:
1. all variable names must start with the dollar sign ($ ).
2. the first character after the dollar sign must be A letter (~ Z, ~ Z) or underscore (_), cannot use numbers
3. the remaining part of the variable name can contain a combination of any number of Ele. me letters, numbers, and underscores.
4. no space is allowed in the variable name (it is usually separated by underscores)
5. the variable name must be unique.
6. variable names are case sensitive !, This means that $ varible and $ Varible are two very different variables. Therefore, it is irrational to name these two variables in such a similar way.
There are also some suggestions to reduce bugs caused by variable naming.
1. all variable names use lowercase letters
2. make the variable name descriptive and try to see its name
3. Use annotations to describe the usage of variables.
4. the most important thing is to maintain consistent variable names.
After the variables are finished, let's take a look at the difference between double quotes and single quotes. The biggest difference between double quotes and single quotes is that the content in double quotes can be replaced, the content in single quotes cannot be replaced,
The code is as follows:
The running result is as follows:
You can see that the result of ¥ result1 is a $ string character, rather than the content of this variable. the content of ¥ result2 is $ string.
You may think these things are simple and easy to remember, but as a coder, small knowledge points, A small program sometimes has a great encouragement for you to learn a language.