PHP Comments

Back to ACP page

Table of Contents

PHP Single Line Comments

<h4>phpSingle_Line_Comments</h4> <p>Single line comments start with //. Any text between // and the end of the line will be ignored (will not be executed). You can also use # for single line comments, but in this tutorial we will use //. The following examples uses a single-line comment as an explanation: </p> <?php // Outputs a welcome message: echo "Welcome Home!"; echo "<br>"; echo "Welcome Home!"; // Outputs a welcome message echo "<br>"; // echo "Welcome Home!"; // echo "<br>"; ?>

Example 1

Result View Example

PHP Multiline Comments

<h4>php-Multiline_Comments</h4> <p>Multi-line comments start with /* and end with */.</p> <p>Multi-line comment as an explanation:</p> <?php /* The next statement will print a welcome message */ echo "Welcome Home!"; ?> <hr> <h4>Multi-line comment to ignore code:</h4> <p>We can use multi-line comments to prevent blocks of code from being executed:</p> <?php /* echo "Welcome to my home!"; echo "Mi casa su casa!"; */ echo "Hello!"; ?> <hr> <h4>Comments in the Middle of the Code</h4> <p>The multi-line comment syntax can also be used to prevent execution of parts inside a code-line:</p> <?php $x = 5 /* + 15 */ + 5; echo $x; ?>

Example 2

Result View Example

Document

Document in project

You can Download PDF file.

Reference