Articles

Learn PHP Commenting

PHP tutorial Lesson 4 Tutorials PHP

Commenting and code writing structure

4. Commenting and code writing structure

When creating your code you may want to keep notes, or even document it. Similar to how you comment in other coding formats, the commenting gets ignored by the server when it constructs the page.

Comments are a great way to keep track of what you are planning and notes in the PHP code itself.
Two forward slashes will comment out the code to the right of the slashes on the same line.

PHP Code example

// echo "This will not be seen";
echo "This will be seen";

To comment out multiple lines you can use the forward slash and asterisk. It would need to be opened using /* and closed */. Anything between those tags will be ignored.

/*

echo "This will not be seen";
echo "More text will not be seen";
echo "More code will not be run";

*/
echo "This will be seen";