Recall & Review
beginner
What is the purpose of comments in PHP?
Comments are used to explain code, make it easier to understand, and to temporarily disable code without deleting it.
Click to reveal answer
beginner
How do you write a single-line comment in PHP?
You can write a single-line comment using either
// or # at the start of the line.Click to reveal answer
beginner
How do you write a multi-line comment in PHP?
Multi-line comments start with
/* and end with */. Everything between is ignored by PHP.Click to reveal answer
beginner
Can comments affect the execution of PHP code?
No, comments are ignored by the PHP engine and do not affect how the code runs.
Click to reveal answer
beginner
Example: What will this PHP code output?<br>
<?php // echo 'Hello'; echo 'World'; ?>
The output will be
World because the first line is a comment and does not run.Click to reveal answer
Which of the following is NOT a valid way to write a comment in PHP?
✗ Incorrect
Option A is an HTML comment, not a PHP comment.
What symbol starts a multi-line comment in PHP?
✗ Incorrect
Multi-line comments in PHP start with /* and end with */.
What happens to the code inside comments when PHP runs?
✗ Incorrect
Code inside comments is ignored by PHP and does not run.
Which comment style can be used for a single line in PHP?
✗ Incorrect
Single-line comments can use // or # in PHP.
Why might a programmer use comments in their PHP code?
✗ Incorrect
Comments help explain code to others or yourself later.
Explain the different ways to write comments in PHP and when you might use each.
Think about quick notes versus longer explanations.
You got /4 concepts.
Describe how comments affect PHP code execution and why they are important.
Consider what happens when PHP runs code with comments.
You got /4 concepts.