25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

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

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

6 ” <strong>PHP</strong> Basics<br />

Comments<br />

Another common part of any programming language is comments. It is a good programming<br />

practice to comment every function, class, method or property in your<br />

code (although you will likely come across lots of code that is poorly commented—or<br />

not at all). Remember—any code that took thought to write will take thought to reread<br />

after several days, months or in some cases, years.<br />

As with tags, <strong>PHP</strong> gives you multiple choices for your comments:<br />

// Single line comment<br />

i<br />

# Single line comment<br />

/* Multi-line<br />

comment<br />

*/<br />

/**<br />

* API Documentation Example<br />

*<br />

* @param string $bar<br />

*/<br />

function foo($bar) { }<br />

Both types of single line comments, // and #, can be ended using a newline (\r, \n or<br />

\r\n) or by ending the current <strong>PHP</strong> block using the <strong>PHP</strong> closing tag—?>.<br />

Because the closing tag ?> will end a comment, code like // Do not show this ?> or<br />

this will output or this, which is not the intended behaviour.<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

Whitespace<br />

Finally, we reach a subject with very little substance (pun definitely intended):<br />

whitespace. <strong>PHP</strong> is whitespace-insensitive, except in a few key areas. This means<br />

that there are no requirements to use (or not to use) a specific type of whitespace<br />

character (e.g.: tabs rather than spaces), or a particular number of whitespace characters.<br />

However, there are a few limitations:

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

Saved successfully!

Ooh no, something went wrong!