用PHP评论其他评论?

Ger*_*zeg 13 php comments

我可以注释掉有其他评论的行吗?

/*
 * comment 1
 */

$var = 0;
$if();

/*
 * comment 2
 */
$var2 = 2;
Run Code Online (Sandbox Code Playgroud)

有没有办法将所有这些线一起注释掉?我经常有很长的功能或逻辑,并想评论其余的测试.

Hea*_*ohn 8

您是否考虑过将代码放在if(0)块中来跳过代码?

例如:

<?php
if( 0 ) {
     print("This code is 'commented' out");


... other commented out code is here ...


}
?>
Run Code Online (Sandbox Code Playgroud)

  • 使用它的另一个好处是,您可以通过在"if"语句中使用类似变量的配置来打开和关闭代码块.例如`if($ debug)`或`if(!$ debug)`. (3认同)