Coding standards and other guidelines

Loïc Hoguin

Anthony Ramine

Youssef Leulmi

This work is licensed under a Creative Commons Attribution 3.0 Unported License.


Table of Contents

1. Coding standards
License
PHP files
Short PHP tags
Example URLs
Naming conventions
Functions, methods, classes, variables
Variable types
Constants
Arguments vs parameters
No global variables
Duplicate code
Comments
Visibility
__toString and Printable
Arrays, ArrayAccess and Mappable
Standard PHP Library
Autoload
Echo, don't print
Do not return error codes, throw exceptions
Put the default values at the end of the arguments list
Add a comma at the end of the array
If, else, elseif
Switch
Quotes
Line breaks
2. PHP style guidelines
Indentation
Curly braces
Control structures
Arrays
Classes
Functions
Function calls
Operators

List of Tables

1.1. List of variable types