Changes

Jump to: navigation, search

Commenting PHP Code

931 bytes added, 19:25, 24 May 2007
PHP Single Line Comments
== PHP Single Line Comments ==
 
Comments that reside on a single line are prefixed with the two forward slash characters in PHP (i.e ''//'').
 
The following example contains a single line comment:
 
<pre>
<?php
 
// This is a single line comment
 
?>
</pre>
 
The single line comment can be on a line of its own, or it can be appended to the end of aline of code:
 
<pre>
<?php
 
echo "This is a test line"; // Output a line of text
 
?>
</pre>
 
In the above example the PHP pre-processor will execute the ''echo'' statement and then ignore everything after the ''//'' single line comment marker.
 
Single line comment markers are also useful for temporarily removing lines of code from the execution flow (particularly useful during debugging sessions). For example the following change to our previous example will cause the PHP pre-processor to ignore the entire ''echo'' command during execution:
 
<pre>
<?php
 
// echo "This is a test line";
 
?>
</pre>

Navigation menu