PHP Comments and its use inside code

First PHP page for Hello world output and checking installation with phpinfo() and uses of comments
 echo 'Hello world'; // this part is commented and not displayed
//echo 'This will not be displayed as commented';
#echo 'this is also commented';
Output is here
Hello world

Multiple Line comments

To comment more than one line or a block of code we can write like this
/* echo ' This is commented ';
echo 'This is also commented ';
echo 'this is also commented, so not displayed';
*/ 
echo 'this is displayed';
Output is here
this is displayed
In this type of code we must write a stop comment also like */ along with start comment like /*

We can comment to part of the line also.
<?php
$v1=3 + /*4 + */ 5;
echo $v1;
?>
Here output is 8 ( Not 12 as 4 is not added )

Comments are used in php to not to execute a part or a line of code. Use of comments is a good practice and it helps in code maintenance for future modification and updating. By using comments we can comment or stop executing on a part of a line or in a block of code.

You can read the HTML comments also. Here basic difference between html comment and php comment is in case of php comments; server never sends them to browser, where as all html comments are posted to browser but browser stops displaying them. Any one can see html comments by checking the view – source of the page.
The comments are inserted in any part of the PHP code.

Introduction to PHP Printing numbers using loop in PHP
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    malik

    08-02-2010

    good very good site
    fazil

    13-10-2012

    I love this site

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer