Front-end PHP primer -003-echo can not do without it, comment on character

Source: Internet
Author: User

Don't be smug, staring at your eyes is useless! Because you're not a genius!
Never deceive yourself, not write code is not.

Don't ask why? I have a headache!

I am in contact with people who think they are very very good x, always ask why so write?
[Heart Spit Groove]: I am not the rule-makers, you are strong to write a language to go!

The basic syntax is the basic rules that make up a programming language and are very specific rules.

For the basic syntax in a programming language:
I think, like the laws of the Earth, there is no way to break the rules.

切记不要犯很多新手一样的毛病——为什么这个基本语法要这样写呢?

We don't want hello world!.

In general, we start with Hello World, but we don't play with him this time!

    1. 找到wamp根目录的www文件夹:E:\wamp64\www
    2. New start.php File
 
   
  
  1. <?php
  2. phpinfo();//用于输入PHP的信息
  3. ?>
    1. Start the Wamp, turn the lower right corner into green! If you can adjust yourself to Chinese better! Found very pit, may be my computer reason or how to, can not adjust the Chinese, did not find the answer! Finally, self-overbearing! Change the configuration file
 
   
  
  1. 找到`wampmanager.conf`文件修改内容如下
  2. 第二行修改为: language ="chinese"

    1. Visit the Address bar to see the results of the http://127.0.0.1/start.php operation
Variables, don't think too complicated!

Now give us two questions and ask the answer:
Excuse me: Sun Honglei and Zhang Yi Hin two classmates

 
   
  
  1. x=4;
  2. y=18;

So how much does x + y equal?
Thinking, two people answered: X + y equals 22.独白:他俩是够2的了

Next we look at the following math knowledge of junior high school, what is the result of X + y?

 
   
  
  1. x=4;
  2. y=18;
  3. x=2;

The result of X + y is 20.这个应该没有疑问吧?

So easy! This is the variable!

Several characteristics of the variable, the Code analysis is as follows
First line: x = 4 assigns the right value 4 to the left X
Second line: x = 18
The result of the execution is: x + y results equal 20 to,
Description x in the top-to-bottom operation (execution), yes 被重新赋值 .

The same is true of our variables in PHP. But there are several features:

    • Have to $ start with. If the variable x has to be written $x don't ask why
    • The first letter of a variable cannot begin with a number
    • The name of the variable is case-sensitive
    • Variables do not use special symbols, Chinese, _ Not special symbols
    • Variable naming is meaningful (don't write XXX,AAA,CCC variable name)见名知意
Echo important partner, do not abandon!

Echo is the most commonly used in PHP output, display function command, has been accompanied by us!

echo pronunciation: [' eko?]
to give an echo;
Function Explanation: output, display

 
   
  
  1. <?php
  2. echo 123;
  3. ?>

Using variable output values

 
   
  
  1. <?php
  2. $iphone = 6088;
  3. echo $iphone;
  4. ?>

You can do an experiment on it.
If you can simply test it, you can also output in HTML! Look what the effect is!

70% Code, 30% comments

The so-called annotation, Chinese interpretation can be: annotations. More accurate. 接触Java的同学,请别弄混了!
Because the code is in English, and the code is long, people will forget it for a long time. Old words good, good head than rotten pen!
So we're going to add a note and a thought to serve others.

There are many features of annotations:

    • Labeling the focus
      • Long time easy to forget quick memories, easy to find
      • Let others see it quickly and read it
      • You can also generate documents, write the relevant documents, and work more efficiently.
      • Comments, blank lines, and carriage return code look more beautiful
      • Comments can be used for troubleshooting. Unsure which piece of code is wrong, you can set a large section of the comment to determine the error interval
      • Note the contents of the middle part of the computer will not execute it

Please be sure to pay attention to the comments, a good habit, not easy!
Let us first look at the code we feel beautiful, neat, normative, clear, a look at understand.
(No need to understand the meaning of the code)

A bit of a bad comment

Annotated family, we simply recognize a few

    • Single-line comment (only one line is commented)
    • Multiline comments (multiple lines of comments)
    • Single-line Comment
 
   
  
  1. // 表示单行注释----推荐方式
  2. # `#`号也表示单行注释,用的比较少
    • Multi-line comments
 
   
  
  1. /*
  2. 多行注释 这里是注释区域代码,还有一种文档注释
  3. */

还记得HTML的注释吗?

Single-line Comment example:

  
 
    1. <? php
    2. //declare a iphone7 phone price variable
    3. $iphone 6_price = Span class= "PLN" > 7088 ;
    4. /span>//display output phone price
    5. echo $iphone 6_price
    6. ?>

Note: Know what the variable does, and also know what the output is for.

Multi-line Annotation Example:

  
 
  1. /*
  2. @author:胖先生
  3. @date:2222.12.22
  4. @desc:这是一个假的多行注释的例子
  5. */
  6. /*
  7. 声明一个爱情变量
  8. $love 是指爱情
  9. 爱情是一个变量,因为人的爱总是在发生变化,但是我没有爱情
  10. 所以,爱情变量的值为250
  11. */
  12. $love = 250;

Note: When we write a lot of comments, we release multiple lines of comments.



From for notes (Wiz)

Front-end PHP primer -003-echo can not do without it, comment on character

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.