Code style of coding specification (IV)

Source: Internet
Author: User

1. Indents and Spaces

When writing code, you must be aware of the code's indentation rules:

Use 4 spaces as indents without using the tab indent

When a variable is assigned, a space is left around the equals sign.

For a greater degree of effort reduction, it is recommended that you use large IDE management code to maintain code aesthetics.

2. Sentence break

Code writing should follow these guidelines:

Try to ensure that the program statement line is a sentence.

Try not to make one line of code too long, usually within 80 characters.

If the line of code is too long, use the ". =" method to write the lines.

When performing SQL statement operations on a database, try not to write SQL statements inside a function, but first define the SQL statement with a variable and then invoke the defined variable in the function that performs the operation.

3. Better habits

Use variables that already exist in PHP, rather than defining them yourself.

Using commas as connectors in echo is more aesthetically pleasing and more efficient than using dot numbers

More detailed comments

Do not abuse grammatical sugars.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Code style of coding specification (IV)

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.