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
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..
*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.
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 (/*…..*/)
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.
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 ?
0 comments:
Post a Comment