Assignment033 - Comments

Up to this point we have rarely commented our HTML. Well, it is now time to start commenting your PHP. We comment in order to speed up maintenance of our code. After not working with a bit of code for a long time, you will have a hard time recognizing what the code means, so COMMENT your code! -_-.

For example:Comments



<html>
<head>
<title>Comments.php</title>
</head>
<body>
<?php
/*
Date: 12/9/09
Programmer: Brock Graham
Purpose: To add up the amount owed to me by my friends
*/
$number1=10//This is the $10 bucks Nick owes me.
$number2=15//This is the $15 bucks Erin owes me.
$number3=5;   #THis is the $5 bucks Justin owes me (plus interest).

$total=$number1+$number2+$number3;
//This creates a variable to hold total owed.

/*
THis section prints to the browser
Its concatinates text, html, and php variable output.
*/
print("<p>The sum of the numbers is ".$total."</p>");
print(
"I have ".($number1+$number2+$number3)." dollars!");
?>
</body>
</html>

PHP allows you to comment your code using three methods:

# This is a single line comment.

// This is also a single line comment.

/* This is a multi-line comment*/