Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTML comment tags for PHP comments.
Using block comment start /* for single-line comments.
✗ Incorrect
In PHP, single-line comments can start with //.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
PHP also supports single-line comments starting with #.
3fill in blank
hardFix 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'
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.
✗ Incorrect
Multi-line comments in PHP start with /* and end with */.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Not closing the multi-line comment.
Using single-line comment syntax for multi-line comments.
✗ Incorrect
Multi-line comments start with /* and end with */ in PHP.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQL comment syntax like -- which is invalid in PHP.
Not closing multi-line comments properly.
✗ Incorrect
PHP supports // and # for single-line comments, and /* ... */ for multi-line comments.