Which syntax is used for multi-line comments in PHP?
A
// Comment // B
/* Comment */ C
# Comment # D
<!-- Comment -->
Analysis & Theory
Multi-line comments in PHP are written using `/* comment */`.
Which of the following is a valid multi-line comment in PHP?
A
/* This is a
multi-line comment */ B
// This is a multi-line comment // C
# This is a multi-line comment # D
<!-- This is a multi-line comment -->
Analysis & Theory
The syntax `/* ... */` is used for multi-line comments in PHP.
What happens if you forget the closing `*/` in a multi-line comment?
A
PHP will ignore the comment. B
The rest of the code becomes part of the comment and causes an error. C
It runs normally. D
It converts it to a single-line comment.
Analysis & Theory
If you forget the `*/`, PHP treats everything after `/*` as a comment, causing syntax errors.
Which is the correct way to comment multiple lines in PHP?
A
/* Line 1
Line 2
Line 3 */ B
// Line 1
// Line 2
// Line 3 C
# Line 1
# Line 2
# Line 3 D
All of the above
Analysis & Theory
All are valid. `/* */` is for multi-line; `//` and `#` can be used repeatedly for single-line comments.
Multi-line comments in PHP can be used for:
A
Documenting blocks of code B
Temporarily disabling multiple lines C
Adding detailed descriptions D
All of the above
Analysis & Theory
Multi-line comments are used for all these purposes.
What is the result of this code?
```
<?php
/* echo 'Hello';
echo 'World'; */
echo 'PHP';
?>
```
A
Hello World PHP B
PHP C
Hello World D
Error
Analysis & Theory
The code inside `/* ... */` is commented out. Only `echo 'PHP';` will execute.
Which of the following is NOT correct for a multi-line comment?
A
/* Comment */ B
/* Comment starts
Comment ends */ C
// Comment line 1
// Comment line 2 D
/* Comment starts
Comment ends
Analysis & Theory
The last option is invalid because it misses the closing `*/`.
Can multi-line comments be nested inside each other in PHP?
A
Yes B
No C
Sometimes D
Only in HTML
Analysis & Theory
PHP does not support nested multi-line comments.
Choose the correct multi-line comment syntax to describe this block of code:
A
/* This block calculates sum */ B
// This block calculates sum C
# This block calculates sum D
<!-- This block calculates sum -->
Analysis & Theory
The syntax `/* ... */` is correct for multi-line comments in PHP.
What is the main difference between single-line and multi-line comments?
A
Single-line comments use `//` or `#`; multi-line uses `/* */`. B
Single-line comments are faster. C
Multi-line comments require semicolons. D
There is no difference.
Analysis & Theory
Single-line comments use `//` or `#` per line. Multi-line comments use `/* ... */` for block commenting.