Style guide for PHP code

Coding conventions for the PHP code of all MMC components.


This document sets the coding conventions for the PHP code of all MMC components (like the MMC web interface for example).

Convention from apply too.

Code layout

Indentation: use 4 spaces per indentation level, no tabs allowed.

Encoding: the source code must always use the UTF-8 encoding.

Code indentation and organisation

block “for”, “function”, “switch”, “if”, etc... always end with opening braces on the same line.


if ($val == value) {
    echo $val;
} else {
    return -1;
foreach ($arrParam as $singleItem) {
    print $singleItem;


Function with long args (more than one line size)





They are written in english.

They always start with a capitalized first word.

There is always a space between the // and the begin of the comment. // and /* are fine. Don’t use #.

All functions must have a correct doxygen header.

Naming conventions

  • ClassName : CapitalizedWords
  • functionName : mixedCase for all function name
  • _membersValue : member value of a class begin with a “_”

PHP language version compatibility

The code must be compatible with PHP 5.0.

PHP error reporting level

All possible PHP errors, warnings and notices must be fixed in the PHP code. Use these lines in your php.ini file when working on the code to find them all:

error_reporting = E_ALL
display_errors = On