2

I have a some piece of code like this. How can I add comments? It has both HTML and PHP combined code.

<?php / echo zen_draw_form('currencies', zen_href_link(basename(ereg_replace('.php', '', $PHP_SELF)), '', $request_type, false), 'get'); ?>

    <div>
        <span class="label"><?php echo BOX_HEADING_CURRENCIES;?>: &nbsp;</span>

        <?php
            if (isset($currencies) && is_object($currencies)) {

                reset($currencies->currencies);
                $currencies_array = array();
                while (list($key, $value) = each($currencies->currencies)) {
                    $currencies_array[] = array('id' => $key, 'text' => $value['title']);
                }

                $hidden_get_variables = '';
                reset($_GET);
                while (list($key, $value) = each($_GET)) {
                    if (($key != 'currency') &&
                        ($key != zen_session_name()) &&
                        ($key != 'x') &&
                        ($key != 'y')) {

                        $hidden_get_variables .= zen_draw_hidden_field($key, $value);
                    }
                }
            }
        ?>
        <?php echo zen_draw_pull_down_menu('currency', $currencies_array, $_SESSION['currency'], 'class="select" onchange="this.form.submit();"') . $hidden_get_variables . zen_hide_session_id()?>
    </div>
</form> */
5
  • And why is this tagged [ajax] Commented Jul 25, 2013 at 9:44
  • <!-- comment --> for html and /* comment */ for php and what is your question? Commented Jul 25, 2013 at 9:45
  • Please have a look Should questions include “tags” in their titles? Commented Jul 25, 2013 at 9:45
  • I think that his issue is that he has mixed PHP and HTML and he want to comment out a mixed part of PHP and HTML Commented Jul 25, 2013 at 9:48
  • Isn't it missing a "*" near "<?php /"? Commented Sep 29, 2021 at 8:29

4 Answers 4

1
<?php
    // PHP comment for one line ?>

    <?php
        /*    This is
              a PHP comment for
              block */
    ?>

For HTML:

<!-- Comment for HTML code
<a href="#">test></a> -->
Sign up to request clarification or add additional context in comments.

Comments

0

Just comment the PHP code inside the PHP tags like this:

<?php
    // This is a PHP comment line

    /*
        This is
        a PHP comment
        block
    */
?>

It doesn't matter if you have everything commented out inside the php tags.

1 Comment

PHP allows for Perl style comments also, like # my comment
0

You can use comment's like this,

<!-- Comment for HTML code
<form>
    <div>
        <?php /* Comment for PHP code */ ?>
    </div>
</form> -->

Comments

0

You have to use different comment styles - one for PHP and one for HTML.

See the example below.

<html>
    <head>

        <!--
        <body>
            <?php

            /* echo 'Hello, World!'; */
            ?>
        </body>

    </head> -->

</html>

1 Comment

With or without the comments, this is not valid HTML (without comments, the HTML body tag is inside the HTML head tag).

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.