Which symbol is used for a single-line comment in PHP?
A
// B
/* */ C
<!-- --> D
--
Analysis & Theory
`//` is used to create a single-line comment in PHP.
Which of the following is a valid single-line comment in PHP?
A
/* This is a comment */ B
# This is a comment C
<!-- This is a comment --> D
-- This is a comment
Analysis & Theory
`# This is a comment` is a valid single-line comment in PHP using the hash symbol.
How many symbols are valid for single-line comments in PHP?
A
1 B
2 C
3 D
4
Analysis & Theory
PHP supports two symbols for single-line comments: `//` and `#`.
Which of the following is NOT a valid way to write a single-line comment in PHP?
A
// This is a comment B
# This is a comment C
-- This is a comment D
//Comment
Analysis & Theory
`--` is not a valid comment syntax in PHP; it is used in SQL, not PHP.
What will happen if you forget to put `//` or `#` before a comment line in PHP?
A
It will be treated as code and may cause an error. B
It will automatically be ignored. C
PHP will convert it into a comment automatically. D
The server will skip it.
Analysis & Theory
If you don’t use `//` or `#`, PHP treats the text as code and may throw a syntax error.
Select the correct syntax for a comment that says 'This is PHP':
A
// This is PHP B
# This is PHP C
/* This is PHP */ D
All of the above
Analysis & Theory
All are correct: `//` and `#` for single-line, and `/* ... */` for multi-line.
Which comment syntax is preferred for inline single-line comments in PHP?
A
// B
# C
/* */ D
<!-- -->
Analysis & Theory
`//` is commonly used and preferred for inline comments in PHP code.
Can the `#` symbol be used for comments in PHP?
A
Yes B
No C
Only in HTML D
Only in SQL
Analysis & Theory
Yes, the `#` symbol is valid for single-line comments in PHP.
Which of the following best describes single-line comments?
A
Comments that start and end on the same line B
Comments that span multiple lines C
Comments that start with /* and end with */ D
None of the above
Analysis & Theory
Single-line comments begin with `//` or `#` and end at the line break.
What is the purpose of single-line comments in PHP?
A
To hide code from execution temporarily B
To cause errors intentionally C
To run faster code D
To output text to the browser
Analysis & Theory
Single-line comments are used to add notes or temporarily disable lines of code without deleting them.