PHP Development variables

Source: Internet
Author: User
Environment has been set up, the following can be happy coding, variables in PHP or more, the following describes some of the rules of naming PHP variables:

1, all variable names must begin with a dollar sign ($)

2, the first character after the dollar sign must be a letter (a~z,a~z) or an underscore (_), you cannot use a number

3, the remaining part of the variable name can contain any number of hungry letters, numbers and underscores of the combination

4, there is no space in the variable name (usually with an underscore for text splitting)

5, variable names must be unique

6, variable names are case-sensitive! , which means that $varible and $varible are completely different two variables, so it is very irrational to name two variables so similar.


There are also some suggestions to reduce the bug caused by the name of the variable.


1, variable names all use lowercase letters

2, let the variable name is descriptive, as far as possible to see its name to know its meaning

3, use annotations to illustrate the purpose of the variable

4, most importantly, to maintain a consistent variable name


The variable is over, let's study, the difference between double and single quotes, double quotation marks and single quotation marks the biggest difference is that the contents of the double quotation marks can be replaced, and the contents of the single quotation mark cannot be replaced,


The code is as follows:

 
  
The results of the operation are as follows:
You can see that the result of ¥RESULT1 is $string character, not the content of this variable, ¥RESULT2 content is $string content.
It may be thought that these things are very simple, but also easy to remember, but as a coder, small knowledge points, small programs sometimes to you learn a language has a team very much encouragement to promote the role OH
  • Related Article

    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.