Search code examples
phpstringcomments

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?


Solution

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