如何在PHP中的字符串内注释

Ami*_*ini 6 php string comments

$var = "a
  b // I want to comment here but it becomes a string instead
  c"
Run Code Online (Sandbox Code Playgroud)

我想在PHP中的多行字符串中间插入注释,但我不能.我试过/**/,//#.

有谁知道怎么做?

Pra*_*ode 10

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

echo $var;
Run Code Online (Sandbox Code Playgroud)


Sco*_*pey 9

只有串联和评论才有可能:

$var = "a\n" .
//     "b\n" .
       "c";
Run Code Online (Sandbox Code Playgroud)

  • 这不是有用的,因为它不打印"b".@Scopey (4认同)