PHP Multiline Comments

0
2K

Multi-line Comments

Multi-line comments start with /* and end with */.

Any text between /* and */ will be ignored.

The following example uses a multi-line comment as an explanation:

ExampleGet your own PHP Server

Multi-line comment as an explanation:

/*
The next statement will
print a welcome message
*/
echo "Welcome Home!";
Try it Yourself »

Multi-line Comments to Ignore Code

We can use multi-line comments to prevent blocks of code from being executed:

Example

Multi-line comment to ignore code:

/*
echo "Welcome to my home!";
echo "Mi casa su casa!";
*/
echo "Hello!";
Try it Yourself »

Comments in the Middle of the Code

The multi-line comment syntax can also be used to prevent execution of parts inside a code-line:

Example

The  + 15 part will be ignored in the calculation:

$x = 5 /* + 15 */ + 5;
echo $x;
Try it Yourself »

PHP Exercises

Test Yourself With Exercises

Exercise:

Use the PHP multi-line comment syntax to make sure the following code lines are not executed:


x = 5;
print(x);


Start the Exercise

 
 

 

 

Search
Categories
Read More
Other
PHP foreach Loop
The foreach loop - Loops through a block of code for each element in an array or each...
By PHP Tutorial 2024-05-17 07:50:19 0 2K
Other
PHP Array Functions
PHP Array Functions PHP has a set of built-in functions that you can use on arrays....
By PHP Tutorial 2024-05-17 08:07:42 1 3K
Other
PHP Create Arrays
Create Array You can create arrays by using the array() function: ExampleGet your...
By PHP Tutorial 2024-05-17 08:01:55 0 3K
Other
PHP Operators
PHP Operators Operators are used to perform operations on variables and values. PHP divides the...
By PHP Tutorial 2024-05-17 07:41:39 0 3K
Other
PHP Comments
Comments in PHP A comment in PHP code is a line that is not executed as a part of the program....
By PHP Tutorial 2024-05-17 07:14:49 0 2K