The Drupal community has defined a set of coding standards and best practices that should be adhered to whenever you're writing code for Drupal. These standards provide a set of rules for how your code should be formatted, whether you should use tabs or spaces, some guidelines around naming conventions, and the location of files. These coding standards ensure consistency in code throughout the project, make it easy for developers to move around from one sub-section to another without having to re-learn how to read the code, and most of all help us to spend our time debating the functionality and logic contained in the code and not the semantics of whitespace. You can simply point to the rules and say, "This is what we agreed on."
This tutorial will cover the PHP coding standards for Drupal, as well as provide some information about why coding standards are important and where you can go to learn more about the coding standards. These standards are Drupal version agnostic and the same rules apply to all versions of Drupal. Once you've completed the tutorial you'll probably want to head over to https://www.drupal.org/coding-standards where the official documentation of the coding standards lives. That page should be considered the canonical source for any questions about the Drupal coding standards.
We're not going to cover every little detail, but we'll make sure and go over the things you're likely to encounter no a daily basis when writing code. By the end of this tutorial you should be ready to start applying the Drupal PHP coding standards to your own custom PHP code and to all your contributions.