comment on php code example
Example 1: comment in php
<?php
*/
?>
Example 2: php proper function comments
Example 3: php comment
<?php
$x = 5 + 5;
echo $x;
?>
Example 4: comment in php
A nice way to toggle the commenting of blocks of code can be done by mixing the two comment styles:
<?php
if ($foo) {
echo $bar;
}
sort($morecode);
?>
Now by taking out one / on the first line..
<?php
sort($morecode);
?>
..the block is suddenly commented out.
This works because a /* .. */ overrides //. You can even "flip" two blocks, like this:
<?php
if ($foo) {
echo $bar;
}
?>
vs
<?php
if ($bar) {
echo $foo;
}
?>
Example 5: comment in php
Comments in PHP can be used for several purposes, a very interesting one being that you can generate API documentation directly from them by using PHPDocumentor (http://www.phpdoc.org/).
Therefor one has to use a JavaDoc-like comment syntax (conforms to the DocBook DTD), example:
<?php
?>
Some basic html-like formatting is supported with this (ie <br> tags) to create something of a layout.
Example 6: comment in php
<?php
echo 'This is a test';
echo 'This is yet another test';
echo 'One Final Test';
?>