-
Notifications
You must be signed in to change notification settings - Fork 673
Code Style Guide: PHP
ginatrapani edited this page Sep 13, 2010
·
20 revisions
This is the Code Style guide for PHP. See the main Code Style Guide page for other languages.
Assume we’re using the Drupal PHP coding style unless otherwise noted here.
Always use <?php
to delimit PHP code, not the shorthand, <?
, as this is the most used and supported across PHP setups and the one PHP will continue supporting in the future.
- Class constructors should be
public function __construct()
. Use destructors when appropriate. - Explicitly declare visibility (public, private, protected) for member variables and methods.
- As per Zend framework style guide, do NOT use PHP closing tags:
“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 white space into the response."
Thinktank uses PHPDocumentor to ease maintenance.. When writing documentation, please use PHPDocumentor’s syntax.
ThinkTank implements the Model-View-Controller design pattern. All new PHP code should follow suit. Read more about ThinkTank’s MVC implementation.