Web Development Tutorials




  
  

Commenting your Code

Comments are used in PHP to allow you to write notes to yourself during the development process. Such comments may define the purpose of a code segment or to comment blocks of code while testing scripts.

Comments are ignored by the PHP parser. PHP comments can be defined in one of the following ways:

// - simple PHP comment

# - alternative simple PHP comment

/*...*/ - multi-line comment blocks.
        
<!DOCTYPE html>
<html>
<head>
 <title>A Web Page</title>
</head>
<body>
 <p>
 <?php 
  // This is a simple PHP comment
  #  This is a second simple PHP comment
 /* This is a PHP multi-line
   comment block. It can span as
  many lines as necessary */
 ?>
 </p>
</body>
</html>
 

TOP | NEXT: Chapter 3 - PHP Data