2

我有一段这样的代码。如何添加评论?它具有 HTML 和 PHP 组合代码。

<?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> */
4

4 回答 4

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

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

对于 HTML:

<!-- Comment for HTML code
<a href="#">test></a> -->
于 2013-07-25T10:00:38.760 回答
1

您必须使用不同的注释样式——一种用于 PHP,一种用于 HTML。

请参见下面的示例。

<html>
    <head>

        <!--
        <body>
            <?php

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

    </head> -->

</html>
于 2013-07-25T10:05:36.637 回答
0

你可以像这样使用评论,

<!-- Comment for HTML code
<form>
    <div>
        <?php /* Comment for PHP code */ ?>
    </div>
</form> -->
于 2013-07-25T09:47:22.573 回答
0

只需在 PHP 标记中注释 PHP 代码,如下所示:

<?php
    // This is a PHP comment line

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

如果您在 php 标记中注释掉了所有内容,这并不重要。

于 2013-07-25T09:45:39.990 回答