In this small and short post i will be showing you how to place comments in your php coding for others to see which does not get shown when the file is executed only viewable in the source code.

First i will show you how to use a single line comment. Which is used just for one line comment.

<?php
// Copyright php2k.com
echo 'Hello world';
?>

The above code will only display “Hello World” not the comment made above it. To make a single line comment you must place “//” in the begining of the line and then make a comment after it.

To make a multiple line comment it is a bit diffrent, example shown below;

<?php
/* Copyright php2k.com
Thank you for using our site
Multiline comment
*/
echo 'Hello World';
?>

The above code will only display “Hello World” when executed in the web browser, but when viewing the source code, the user will see the comment made by the creator. To make a multiple line comment you must place “/*” in the begining of the comment, and when finished place “*/” placing your comment in between.

Hope this post has helped you, if you need any help please make a comment and i will get back to you as soon as possible.

Leave a Reply

You must be logged in to post a comment.