10.02.2013 Views

PHP Programming Language - OpenLibra

PHP Programming Language - OpenLibra

PHP Programming Language - OpenLibra

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PHP</strong>Doc 174<br />

<strong>PHP</strong>Doc<br />

<strong>PHP</strong>Doc is an adaptation of Javadoc for the <strong>PHP</strong> programming language. It is a formal standard for commenting<br />

<strong>PHP</strong> code. It allows external document generators like phpDocumentor to generate documentation of APIs and helps<br />

some IDEs such as Zend Studio, NetBeans, ActiveState Komodo Edit and IDE and Aptana Studio to interpret<br />

variable types and other ambiguities in the loosely typed language and to provide improved code completion, type<br />

hinting and debugging.<br />

<strong>PHP</strong>Doc supports documentation of both object-oriented and procedural code.<br />

Components of <strong>PHP</strong>Doc<br />

DocBlock<br />

A DocBlock is an extended C++-style <strong>PHP</strong> comment that begins with "/**" and has an "*" at the beginning of every<br />

line. DocBlocks precede the element they are documenting. Any line within a DocBlock that doesn't begin with a *<br />

will be ignored.<br />

To document function "foo()", place the DocBlock immediately before the function declaration:<br />

/**<br />

* This is a DocBlock comment<br />

*/<br />

function foo()<br />

{<br />

}<br />

This example will apply the DocBlock to "define('me',2);" instead of to "function foo()":<br />

/**<br />

* DocBlock for function foo?<br />

*<br />

* No, this will be for the constant me!<br />

*/<br />

define('me',2);<br />

function foo($param = me)<br />

{<br />

}<br />

define() statements, functions, classes, class methods, and class vars, include() statements, and global variables can<br />

all be documented, see Elements of the source code that can be documented<br />

A DocBlock contains three basic segments in this order:<br />

• Short Description<br />

• Long Description<br />

• Tags<br />

The Short Description starts on the first line, and can be terminated with a blank line or a period. A period inside a<br />

word (like example.com or 0.1 %) is ignored. If the Short Description would become more than three lines long,<br />

only the first line is taken. The Long Description continues for as many lines as desired and may contain HTML

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!