Style Guide

The following describes programming style which is recommended and best practices when developing with WHASOLS.

PHP Code Tags
Always use to delimit PHP code, not the shorthand, . This is the most convincing portable format to ensure compatibility for differing operating systems and set-ups.

If a file is pure PHP code, it is desireable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag which may cause unwanted side effects comprising “header already sent” errors, XHTML/XML validation issues, and other problems.

Indenting And Whitespace
Use an indent of 4 spaces, with no tabs.

Lines should not have any trailing whitespace at the end.

Files should be formatted with \n as the line ending (Unix line endings), not \r\n (Windows line endings).

All files should end in a single newline (\n). This avoids the verbose “\ No newline at end of file” warning and makes it more clear what is being changed when lines are added to the end of a file.

PSR Coding Standards
The PHP Standard Recommendation (PSR) is a PHP specification that is published by the PHP Framework Interop Group. It comprises what should be considered the standard coding elements which are required to ensure a high level of technical interoperability between shared PHP code.

At WHASOLS we follow the PSR-1 and PSR-2 standards for all code we create, and we strongly recommend you to do the same:

Character Encoding
All PHP files should be encoded using UTF-8 without BOM (no byte-order-mark).