";php注释“;在echo语句中


"php comment" within an echo statement

如何处理echo命令中间的注释?

这个语法给我带来了一个语法错误,但为什么不符合?

<?
echo "Print this " . /*but not this*/ . " and this'n";
?>

我是不是被迫写三份单独的声明?

<?
echo "Print this "
/*but not this*/
echo " and this'n";
?>

因为它解析为:

echo "Print this " .  . " and this'n";

这是一个语法错误,这也是:

echo "Print this " echo " and this'n";

除了内部字符串文字外,在执行时代码中实际上不存在注释。

在注释中包括第二个(或第一个).

echo "Print this " . /*but not this .*/ " and this'n";

这将使其下定决心:

echo "Print this " . " and this'n";