PHP Comments Tutorial
PHP - Comments
In PHP there are two main ways to write comments
- Single Line Comments
- Multiple Line Comments
Comments in PHP are different to comments in HTML in that by simply viewing the html source code will not enable you to view your PHP comments; the only way to view PHP comments is to open the PHP file for editing.
HTML comments are wrote like <!—My html comment à
Single Line comments in PHP
In PHP Single line comments are written using two forward slashes, "//" or "#" the hash key. The single line comment tells the interpreter to ignore everything that occurs on that line to the right of the comment.
Let’s take a look at an example.
Example - Single Line Comments
In the above example we described the echo line code using a single line comment "// print Welcome on the screen". Notice that our comment is not displayed on the screen also if you view the source code you will not see the comment. Multiple Line Comments in PHP In PHP Multiple line comments begin with "/*" and ends with "*/". So, anything inside /* */ will be treated as comments by the PHP interpreter. Multiple line comments are normally used when you have to explain a rather long block of code instead of one line. Example - Multiple Line Commentsmy first php page <?php // print out welcome to the screen echo "Welcome!"; ?>
Thats It.
![]() |
