2

I need to comment some lines of code that already contain other comments,
I tried to do something like this:

...
<?php /* ?>
<ul>
    <li></li>
    <li></li>
    <li></li>
    <?php /* ?>
    <li></li>
    <li></li>
    <?php */ ?>
    <li></li>
    <li></li>
    <li></li>
</ul>
<?php */ ?>
...

but it does not work. How can I do it?

2

3 Answers 3

3

From the PHP documents: http://php.net/manual/en/language.basic-syntax.comments.php

'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.

So you cannot nest multi-lined comments.

Sign up to request clarification or add additional context in comments.

1 Comment

No. It might help if you were to edit you question or provide more information on what it is you're trying to do though. There could be other ways to accomplish the same task.
0

Unfortunately you cannot. However, depending on what your code is actually doing, you may be able to get away with commenting out the HTML outputted by the php. Like this:

<!--
<ul>
    <li></li>
    <li></li>
    <li></li>
    <?php /* ?>
    <li></li>
    <li></li>
    <?php */ ?>
    <li></li>
    <li></li>
    <li></li>
</ul>
-->

Comments

0

No you can't use multi-line php comment nested. Multi-line comment starts at the first

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.