Documentation

Features

This is an old revision of the document!


Coding Standards

This document provides guidelines for code formatting and documentation to individuals and teams contributing to 68 Classifieds

Commenting

In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.

DocBlock style comments preceding class and method declarations so they can be picked up by IDEs:

/** 
* My Class
* 
* @package Example Package
* @subpackage Subpackage 
* @category Category 
* @author Author Name 
* @link http://yoursite.com 
*/ 
class Super_sweet {

PHP Closing Tag

For files that contain only PHP code, the closing tag (”?>”) is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.

Indentation

Indentation should consist of 1 tab.

Line Termination

Line termination follows the Unix text file convention. Lines must end with a single linefeed (LF) character. Linefeed characters are represented as ordinal 10, or hexadecimal 0x0A.

Note: Do not use carriage returns (CR) as is the convention in Apple OS's (0x0D) or the carriage return/linefeed combination (CRLF) as is standard for the Windows OS (0x0D, 0x0A).

Short Open Tags

PHP code must always be delimited by the full-form, standard PHP tags:

<?php
 
?>

Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted

if ($a != 2) 
{
  $a = 2;
} 
elseif ($a == 3) 
{
  $a = 4;
} 
else 
{
  $a = 7;
}

Have more questions? Visit our community forums.