$var = "a
b // I want to comment here but it becomes a string instead
c"
I want to insert a comment in the middle of multiple line string in PHP, but I can't. I've tried /**/
, //
, and #
.
Does anyone know how to do it?
Single-line PHP Comments To leave a single-line comment, type two forward slashes (//) followed by your comment text. All text to the right of the // will be ignored. You can also use a hash symbol (#) instead of // to make a single-line comment.
PHP Comments Multi Line Comments The multi-line comment can be used to comment out large blocks of code. It begins with /* and ends with */ .
PHP supports both one-line and multi-line comments. A one-line comment starts with the # or // . A multi-line comment starts with /* and end with */ .
The comment syntax used in PHP is similar to other standard programming languages like C, C++, Java, etc. The comment can be a single-line and multi-line.
$var = "a
b ".// I want to comment here but it becomes a string instead."
"c";
echo $var;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With