In this tutorial you will learn about the PHP Coding Standard and its application with practical example.
There are few points need to be followed while coding in PHP.
- Proper Indenting and line space
- Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.
- You are strongly encouraged to always use curly braces even in situations where they are technically optional.
- Code should be properly commented using C style comments (/* */) and standard C++ comments (//) are both fine. Its increase the readability.
- Always use <?php ?> to delimit PHP code, not the <? ?> shorthand.
- There should be only one statement per line unless it will create a mess.
- Block of declarations should be aligned.
- Proper Identifier naming convention is necessary.