PHP Multiple Line Comment inside Multiple Line Comment PHP Multiple Line Comment inside Multiple Line Comment php php

PHP Multiple Line Comment inside Multiple Line Comment


From the PHP manual:

'C' style comments end at the first */ encountered. Make sure you don't nest 'C' style comments. It is easy to make this mistake if you are trying to comment out a large block of code.

<?php /*    echo 'This is a test'; /* This comment will cause a problem */ */?>

:(


There's no nice way to do this so what I usually do is to just use the following workaround:

<?php if(false): ?>Whatever needs to be commented out.<?php endif; ?>


By design PHP syntax won't allow to do that.

So I think the easiest way to achieve that would be to remove all / characters followed by *.

In example, the following code:

/*  /*   * Comment 1   */  /*   * Comment 2   */*/

would become:

/*  /*   * Comment 1   *  /*   * Comment 2   **/