What are the differences between the two coding styles?

Source: Internet
Author: User
PHP code: {code...} I remember where I saw it before. I recommend writing 1. I don't know why? PHP code:


  

I remember where I saw it before. I recommend writing 1, but I don't know why?

The problem has been disabled. cause:

Reply content:

PHP code:


  

I remember where I saw it before. I recommend writing 1, but I don't know why?

How can I write it easily!

There should be no difference, just to look good ..
For example, var = a; is the same as var = a; and I like the latter for good looks.

No difference
For example, a php function
Function fun1 ($ str1, $ str2 ){
}
The two parameters are separated by commas (,). However, for good looks, the comma is followed by a space.

The file size is only 2 bytes.

The first writing method should be more intuitive to the senses and won't be difficult to read because the code is too compact.

Find a encoding specification, according to the encoding Specification

There are still some differences. When spaces are added, the file size will increase. Haha. I personally think this is my habit.

For example.

for(int i=0,j=0;i<10&&j<100;i++,j++){    some_function();}

And

for(int i = 0, j = 0; i < 10 && j < 100; i++, j++){    some_function();}

Which one is quite readable!

There is no problem with the two styles, that is, they comply with the specifications,

But the key point is:

Use a standard/style from the beginning in the Code. If the above two styles/specifications are used for MashUps, they are neither beautiful nor correct.

No difference. The encoding style does not involve syntax. It is good for the compiler to understand it. But the code is written by people, so you should be clear about it in order to treat yourself well to others. If we don't talk about other encoding styles, let's talk about the layout mentioned here. It uses spaces, line breaks, and alignment to organize the code according to its logic (due to errors), which is also helpful for quick understanding of the Code. Another important point is that the style of the entire project code should be consistent! What you wrote should be consistent with what other project members wrote! Whether this style is used or that style is not that important.

By default, zend studio format is the first type. However, it is more common than the second standard. It mainly depends on the Unified overall code!

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.