Home > Backend Development > PHP Problem > How to indent php code?

How to indent php code?

青灯夜游
Release: 2023-02-26 10:34:01
Original
5137 people have browsed it

How to indent php code?

When writing code, you must pay attention to the indentation rules of the code. We stipulate the code indentation rules as follows:

Use 4 spaces as indentation instead of Use tab indentation (for ultraedit, you can set it in advance)

Example:

for ( $i=0;$i<$count;$i++ ){
    echo "test";
}
Copy after login

php code writing specifications

● Code The encoding conventions in psr-1 must be followed.

●The code must be indented using 4 spaces instead of the tab key.

●The number of characters in each line should be softly kept within 80. In theory, it must not be more than 120, but there must be no hard limit.

● A blank line must be inserted after each namespace declaration statement and use declaration block.

●The opening brace ({) of a class must be written on its own line after the class declaration, and the closing brace (}) must also be written on its own line after the class body.

●The opening brace ({) of a method must be written on its own line after the function declaration, and the closing brace (}) must also be written on its own line after the function body.

●The properties and methods of the class must be added with access modifiers (private, protected and public), abstract and final must be declared before the access modifier, and static must be declared after the access modifier.

● There must be a space after the keyword of the control structure, but it must not be when calling a method or function.

● The opening brace ({) of the control structure must be written on the same line as the declaration, and the closing brace (}) must be written on its own line after the body.

● There must be no spaces after the opening left bracket and before the closing right bracket of the control structure.

The above is the detailed content of How to indent php code?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template