- PHP

How to make PHP comment

Comments are used to describe the logic behind some more complicated code functionality. This is useful not only for other developers but also for us if we return to code after a long break. Comments are also used, among other things, to describe licenses, changes, or even to temporarily disable some part of the code.

There are three popular ways of commenting in PHP:

1-line double slash // comment:

<?php

$hello = 'Hello World!'; // Hello World!

?>

1-line shell style-comment #:

<?php

$x = 2 + 2 * 2; # it's 6!

?>

Multi-line comments with /* and */:

<?php

/*
    This comment 
    can have
    multiple lines

    Awesome!
*/

    echo 'Hello!';
?>

There is no better or worse. Usually, PHP programmers use double slash // comment for single-line comments and /* comment */ for multi-line comments.