0
0
PHPprogramming~10 mins

Comments in PHP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a single-line comment in PHP.

PHP
<?php
[1] This is a comment
echo "Hello World!";
?>
Drag options to blanks, or click blank then click option'
A#
B<!--
C/*
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTML comment tags for PHP comments.
Using block comment start /* for single-line comments.
2fill in blank
medium

Complete the code to add a single-line comment using an alternative syntax.

PHP
<?php
[1] This is another single-line comment
echo "Hello again!";
?>
Drag options to blanks, or click blank then click option'
A/*
B#
C//
D--
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQL comment syntax like -- which is not valid in PHP.
Using block comment start /* for single-line comments.
3fill in blank
hard

Fix the error in the code to properly write a multi-line comment in PHP.

PHP
<?php
[1] This is a
multi-line comment */
echo "Done!";
?>
Drag options to blanks, or click blank then click option'
A/*
B//
C#
D<!--
Attempts:
3 left
💡 Hint
Common Mistakes
Using single-line comment syntax for multi-line comments.
Using HTML comment tags which do not work in PHP.
4fill in blank
hard

Fill both blanks to correctly write a multi-line comment in PHP.

PHP
<?php
[1] This is a
multi-line comment [2]
echo "Finished!";
?>
Drag options to blanks, or click blank then click option'
A/*
B//
C*/
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Not closing the multi-line comment.
Using single-line comment syntax for multi-line comments.
5fill in blank
hard

Fill all three blanks to write a PHP script with different comment styles.

PHP
<?php
[1] This is a single-line comment
[2] This is another single-line comment
[3] This is a multi-line comment start
This is inside the comment
*/
echo "Comments done!";
?>
Drag options to blanks, or click blank then click option'
A//
B#
C/*
D--
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQL comment syntax like -- which is invalid in PHP.
Not closing multi-line comments properly.