Php development variables

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.