PHP Multiline Comments

Multiline Comments

Multiline comments in PHP start with /* and end with */. Any text between these markers will be ignored by PHP.

Tutorials dojo strip




Example: Multiline Comment as an Explanation

<?php
/*
The following statement will
print a welcome message
*/
echo "Welcome Home!";
?>




Using Multiline Comments to Ignore Code

Multiline comments can also be used to prevent blocks of code from being executed. This can be particularly useful when you need to temporarily disable parts of your code.

Example: Multiline Comment to Ignore Code

<?php
/*
echo "Welcome to my garage!";
echo "Feel free to browse the cars and motorcycles!";
*/
echo "Hello!";
?>




Comments Within Code

Multiline comments can also be used within a line of code to ignore certain parts of it.

Example: Ignoring Parts of Code

In this example, the + 15 part will be ignored in the calculation:

<?php
$x = 5 /* + 15 */ + 5;
echo $x; // Output will be 10
?>
Tutorials dojo strip
Scroll to Top