php resource centre

  • about
  • articles
  • tutorials
  • resources
  • certification
Home

Primary links

  • About
  • Articles
  • Tutorials
  • Resources
  • Certification

PHP Coding Standards - II

admin — Tue, 22/08/2006 - 3:47pm

Function and Class Comments: Similarly, every function should have a block comment specifying name, parameters, return values, and last change date.



/** * brief description. * long description. more long description. * * @author firstname lastname email * @param variable description * @return value description * @date YYYY-MM-DD * @deprecated * @see * */

Note

The placement of periods in the short and long descriptions is important to the PHPdoc parser. The first period always ends the short description. All future periods are part of the long description, ending with a blank comment line. The long comment is optional.

Indenting

All indenting is done with TABS. Before committing any file to CVS, make sure you first replace spaces with tabs and verify the formatting.

PHP Tags

The use of < ?php ? >to delimit PHP code is required. Using < ? ? >is not valid. This is the most portable way to include PHP code on differing operating systems and webserver setups. Also, XML parsers are confused by the shorthand syntax.

Templating

In the SourceForge system, PHP itself is used as the template language. To make the templating clearer, template files should be separated out and included once objects and database results are established. Detailed examples are in the docs repository and online at:

Templating

Variables in the templates are presented surrounded by < ?php ? >tags instead of the {} tags that some other template libraries would use. The end result is the same, with less bloat and more efficient code.

Expressions

Use parentheses liberally to resolve ambiguity. Using parentheses can force an order of evaluation. This saves the time a reader may spend remembering precedence of operators.Don't sacrifice clarity for cleverness. Write conditional expressions so that they read naturally aloud. Sometimes eliminating a not operator (!)will make an expression more understandable. Keep each line simple. The ternary operator (x ? 1 : 2)usually indicates too much code on one line. if... else if... elseis usually more readable.
  • Tutorials
  • Login to post comments

User login

  • Request new password

Follow Us

Who's online

There are currently 0 users and 1 guest online.

Who's new

  • Nisha
  • linnaeus
  • Yameen
  • TalleyReedy
  • admin

Follow vipin7873 on Twitter

<!-- Start of Woopra Code -->

<!-- End of Woopra Code -->

  • about
  • articles
  • tutorials
  • resources
  • certification

copyright © 2010 Vipin Chandran