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> */
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Aqib Bashir
  • 49
  • 1
  • 7

4 Answers4

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> -->
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mike Phils
  • 3,475
  • 5
  • 24
  • 45
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shane van Wyk
  • 1,870
  • 1
  • 26
  • 62
0

You can use comment's like this,

<!-- Comment for HTML code
<form>
    <div>
        <?php /* Comment for PHP code */ ?>
    </div>
</form> -->
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
n8coder
  • 691
  • 4
  • 12
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>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Naveen
  • 7,944
  • 12
  • 78
  • 165