Alex Rivera | Logout

Multiple line comment inside multiple line comment in PHP

Asked 2011-08-08T03:51:32.310
18
<?php
/*
    /* this is a comment */
*/
?>

PHP returns "syntax error"... Is this just a completely wrong way to use multiple line comment?

Sometimes I need to comment out a big block of code for testing, and this block contains hundreds of lines and there are many multiple line comments inside.

What's the best way to comment out this big block? Besides removing it temporarily from the file?

Edit
Report

1 Answer

1

I'd say it depends on your IDE/editor. Some IDE's have a "comment" feature, which will do single-line comments (//) on all lines of a selected area, so you would select the whole range and click that button.

If your IDE doesn't have that feature, then I think you're out of luck.

For example, suppose this is your original code

$a = 1; /* sets a = 1 */
$b = 2;
/*
    blah blah
*/

If you highlight that whole thing in some IDEs and click the comment button, you'll end up with:

// $a = 1; /* sets a = 1 */
// $b = 2;
// /*
//     blah blah
// */

The // comments win, which mean you just did what you're trying to accomplish.

answered 2011-08-08T03:56:09.597

Your Answer