3/22/15

PHP Comments


A comment is non-executable lines. comment is used to write description  for your own understanding.Browser doesn’t read the comments.

There are two types of comments used in php

1. Single line comments :

Single line comment used for short explanations.
Declaration of Single line comment are two types
Either Begin with(#) Or backslash(//)
Eg i
 
   <?php 
   # This is the single line comment
 # This is the next line comment
        // This is also a single line comment.
    ?>
In the above Example.
*First and second line comments begin with hash(#).
*The third one is begin with(//).
If we check the output of the given example.
Browser show blank page. Beacuse comments are always non-executable..
 
Eg ii
 
   <?php 
   $str= "welcome ";
       //$str. =" student";
       echo $str;  
    ?>
  
    Output : welcome
In the above Example.
We daclare a variable to store the String(“welcome”)
In second line we concatinate string(“student”) with the Previous string(“welcome”)
In third line we check the output.It shows Welcome Only. Because the second line statement has already specify a comment statement.
So it can’t take the string(“student”) as a declaration.

2. Multi-lines comments :

Multi lines comments  used to comment multiple lines.
Here we can give comments in bulk
The bulk comments are enclose within (/*…..*/)
Eg i
 
   <?php 
  /* 
 This is a comment with multiline 
        Developer : sanjeev rai 
 View : Multiline Comments Demo 
 */
   ?>

The all lines which is define in php evironment are Multiline comments.
it is non-executable.Because it enlose with Multiline comments statement.
 
Eg ii
 
   <?php 
  /*
        $str = "welcome ";
        $str.= "users ";
         */
        echo "Hello user how are you ? ";
   ?>


    Output : Hello user how are you ?

Related Posts:

  • Difference between $ and $$ Variables in PHP $$var uses the value of the variable whose name is the value of $var. It means $$var is known as refrence variable where… Read More
  • PHP Variables Variables in PHP Variable is nothing it is just name of the memory location. A Variable is simply a container i.e used to store both nu… Read More
  • PHP Super Global Variables PHP super global variable is used to access global variables from anywhere in the PHP script. PHP Super global variables is accessible insid… Read More
  • PHP Introduction PHP Three letters that together constitutes the name of one of the world’s most popular programming languages for Web development, the … Read More
  • PHP Syntax PHP Environment Start – End syntax is a way to representation of PHP script. Basically it gives the primary idea to specify the code for… Read More

0 comments:

Post a Comment

FIND US ON FACEBOOK

FIND US ON Twitter