How can I properly outcomment this PHP code? [closed]

天涯浪子 提交于 2019-12-02 13:45:49
<?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
?>

Depending on whether you want the comments to be propagated to the browser or not:

<?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>
kingkode

Like this:

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

But I generally delete or replace that entire block.

H2ONOCK
/* multi-line quote */

For a single line quote just type a hash (#) before it.

Si8

You have multiple ways to comment in PHP:

/* INFO */ for multiline comments
# INFO  for single-line comments
// INFO for single-line comments
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!