<?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.
So what's the best way to comment out this big block? besides removing it temporarily from the file?
Quick solution for the nested comment:
Turn the closing
*/
into a* /
In other words: Just set one whitespace.
From the PHP manual:
:(
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:
would become:
There's no nice way to do this so what I usually do is to just use the following workaround:
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
If you highlight that whole thing in some IDEs and click the comment button, you'll end up with:
The
//
comments win, which mean you just did what you're trying to accomplish.for smart move just add and save you whole desire comment code section in "yourCodeBlock.php"then
or simple single line comment