How To Comment A PHP Code With Different Methods In PHP

admin_img Posted By Bajarangi soft , Posted On 16-09-2020

A comment in PHP code is a line that is not executed as a part of the code and Its only purpose is to be read by users.

comment a PHP code in website

List of Comment a PHP code in website

1.A comment in PHP code is a line that is not executed as a part of the program.
2.It is a good practice of coding so that coder and the reader can get help to understand the complex code.
3.Comments are not displayed in the output, they are ignored by the PHP engine.
4.Let other coder can also understand your code
5.Reminds what we did in program.

 

There are several ways of commenting line in PHP:
 

single-line comments:
for example:

<?php
// This is a single-line comment

# This is also a single-line comment
?>


multiple-line comments:
for example:

<?php
/*
In PHP we can comment
 multiple-lines of code
so we can comment mutliple-lines 
*/
?>


Complete Code to comment a PHP code in website :
 

<!DOCTYPE html>
<html>
<head>
    <title>comment a PHP code in website</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <br>
    <br>
    <div class="text-center">
        <h1>comment a PHP code in website</h1>
    </div>
    <br>
    <br>
    <div class="well">
        <?php
        $a=5;//initialization 5 to a variable
        $b=5;# initialization 5 to b variable
        /*
        add a to b and store in c variable
        and echo c value
        */
        $c=$a+$b;
        echo "<h1>".$c."</h1>";//output
        ?>
    </div>
    <br>
</div>
</body>
</html>

Related Post