Commenting Code in PHP

Commenting your code is a good habit to have. Entering comments in HTML documents helps you (and others who might have to edit your document later) keep track of what’s going on in large documents. Comments also allow you to write notes to yourself during the development process or comment out parts of code when you are testing your scripts, so the code is not executed.

HTML comments are ignored by the browser and are contained within <!-- and --> tags. For example, the following comment reminds you that the next bit of HTML code contains a logo graphic:
<!-- logo graphic goes here -->

PHP uses comments, too, which are ignored by the PHP parser. PHP comments are usually preceded by double slashes, like this:

// this is a comment in PHP code

But you can use other types of comments, such as
# This is shell-style style comment

/* This begins a C-style comment that runs onto two lines */

No comments:

Post a Comment