Grow your CSS skills. Land your dream job.

Last updated on:

Comments in PHP

<?php

    /*
           This code by Chris Coyier
    */

    $i = 0;    // counter to be used later;

?>

Comments in PHP can be between /* */ markings (useful for multiple line comments) or after // markings (for single lines only).

Comments

  1. Permalink to comment#

    Have you tried the other type of comments? you use the # sign and they work like // comments.


    # like this

  2. Brad
    Permalink to comment#

    Can you help me with a small text based counter script ? It says something like permission error.

  3. Permalink to comment#

    I think its best to avoid using the multiline version for short blocks if you can.
    The reason is that they don’t nest well. So if you use, “/asterisk A comment asterisk/”
    in a
    function and latter comment out the function with “/asterisk asterisk/”. You wont get what you want.
    For example:

    /*
    function test()
    {
    /*This is a comment */

      invade_mars();
    

    }

    */

  4. We can also use hashes (#) for comment

    Eg:

    <?php
    #Your comment
    ?>
    

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
    ``` 
    <div>
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
    </div>
    ```
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".