PHP Programing language

adplus-dvertising
PHP Comments
Previous Home Next

In PHP the Comments are using just Like as Similar to to comments that are used in HTML. The comment is started with a special character and a sequence and all the text that appears between the start of the comment and the end will be ignored by the browser.

In Html in using comment only purpose to serve a note to you, and the web developer or to others who may viewing your website's source. However, The PHP's comments are different in that they will not be displayed to your visitors. The only way to view PHP comments is to open the file for editing, which makes PHP comments useful only PHP programmers.

<<<---For example of HTML Comment--->>>

Single Line Comment

In HTML holds only one kind of comment. However, in this PHP there are two kinds. In this PHP the first we will discuss is the single line comment. The single line comment is tells the interpreter to ignoring everything that occurs on that line, to the right of the comment. To do a single line comment type "//" and all text that follows will be commented out.

Notice: That The couple of our echo statements were not evaluated because we commented them out with the single line comment. This type of line commenting is often used for quick notes about complex and confusing code or to temporarily remove a line of PHP code.

<?php
 echo "The very good site for r4rtechsoft"; 
 echo "<br />Psst...You can't see my PHP comments!"; // echo "nothing";
 // echo "it's a educational site for more valuable";
 ?>

Multiple Line Comment

The similarly to the HTML comment, the multiple line PHP comment can be using to comment out for large blocks of code or writing multiple line comments. In PHP multiple line comment begining with " /* " hello " */ ".

<?php
/* This Echo statement will print out my message to the
the place in which I reside on. In other words, the World. */
echo "r4rtechsoft!";
/* echo "it's more valuable sites!";
echo "and the sites are beginning for PHP comments!";
*/
?>

The best comment practice that I can recommend to new PHP programmers is....USE THEM!! it's So many people write complex PHP code and are either too lazy to write good comments or believe the commenting is not needed. However, do you really believe that you will remember exactly what you were thinking when looking at this code a year or more down the road?

Let the comments permeate your code and you will be a happier PHP in the future. Use single line comments for quick notes about a tricky part in your code and use multiple line comments when you need to describe something in greater depth than a simple note.

Previous Home Next