-11

我有这个代码:

<?php do_action('twentytwelve_credits'); ?>

<a href="<?php echo esc_url(__('http://wordpress.org/', 'twentytwelve')); ?>" 
   title="<?php esc_attr_e('Semantic Personal Publishing Platform', 'twentytwelve'); ?>"
><?php printf(__('Proudly powered by %s', 'twentytwelve'), 'WordPress'); ?></a>

我应该如何评价它?

4

5 回答 5

4
<?php
    echo 'This is a test'; // This is a one-line c++ style comment
    /* This is a multi line comment
       yet another line of comment */
    echo 'This is yet another test';
    echo 'One Final Test'; # This is a one-line shell-style comment
?>
于 2013-04-01T20:31:56.357 回答
1

取决于您是否希望将评论传播到浏览器:

<?php 
/* This very interesting comment won't show in the content sent to the browser
 */
do_action( 'twentytwelve_credits' ); 
// or some end of line comment, not forwarded to the browser either
?>
<!--
But this one will
-->
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentytwelve' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentytwelve' ), 'WordPress' ); ?></a>
于 2013-04-01T20:33:01.150 回答
0

像这样:

<?php /*do_action( 'twentytwelve_credits' ); ?>
        <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentytwelve' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentytwelve' ), 'WordPress' ); ?></a>
*/ ?>

但我通常会删除或替换整个块。

于 2013-04-01T20:30:31.687 回答
0
/* multi-line quote */

对于单行引号,只需在其前面键入一个井号 ( #) 或双斜线 ( //)。

于 2013-04-01T20:31:24.390 回答
0

在 PHP 中有多种注释方式:

/* INFO */ for multiline comments
# INFO  for single-line comments
// INFO for single-line comments
于 2013-04-01T20:33:03.237 回答