Everyone should follow some coding standards. It is required because there may be many developers working on different modules of one project; if they follow their own standards the code may become very un-manageable. It is very difficult to maintain the code in future.

Reasons to follow standards:

  1. Your co-programmers should understand your code. A coding standard acts like a blueprint for the team.
  2. Simple and clear code will reduce your common mistakes.
  3. If you revise your code after some days, it is easy to understand that code.
  4. For best quality project you should follow the coding standards.

Here are some coding tips to follow for better result:

  1. Text indenting and line length: It is better to maintain text indenting and particular line length while coding. For text indenting use four spaces instead of tab, because different computers may take different settings for tab. It is better to maintain the line length approximately 75-85 characters long for better reading.
  2. Control structures: Control statements should have one space between keyword and opening parenthesis, to make a difference between function calls and control statements. It is recommended to use curly braces even though it is optional.
  3. Function calls: Functions should be called with no space between name and opening parenthesis, and the first parameter, spaces between commas and each parameter, and no space between last parameter and closing parenthesis.
  4. Function definitions: Function names should follow the allman style.
  5. Comments: Use C style comments (/* */) and standard C++ (//) style comments.
  6. Variable names:
      • Use lower case letters
      • Use ‘_’ as word separator.
      • Global variables should be prepended with ‘g’
      • Static variables should be prepended with ‘s’
      • Global constants should be all caps with ‘_’ separator

7. One statement per one line

Here is the set of tips to follow to become a good PHP developer.

  1. Don’t use PHP short tags:

Short_open_tags is an ini setting. By default it is enabled in PHP 5.3, but every server not run PHP 5.3. It is more important to use PHP full tags in compatibility and portability.

       2. Stop using MySQL Library:

It is better to stop using MySQL library functions as they have not updated in some time.

Use MySQLi or PDO

       3. Use array functions and string functions:

While working with arrays and strings it is more important to use functions instead of writing your own code.