Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to comment inside a string in PHP

$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?

like image 500
Aminah Nuraini Avatar asked Apr 12 '16 05:04

Aminah Nuraini


People also ask

How do I comment inside a PHP code?

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.

How do you comment multiple lines in PHP?

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 */ .

What are the two types of comment tags in PHP?

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 */ .

Is a single line comment operator used in PHP?

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.


1 Answers

$var = "a
  b ".// I want to comment here but it becomes a string instead."  
  "c";

echo $var;
like image 148
Prassd Nidode Avatar answered Oct 04 '22 09:10

Prassd Nidode