Skip to content

Instantly share code, notes, and snippets.

@ta-riq
Created December 11, 2017 18:02
Show Gist options
  • Select an option

  • Save ta-riq/3806a018805b13a68dea78ac6aeeb0dc to your computer and use it in GitHub Desktop.

Select an option

Save ta-riq/3806a018805b13a68dea78ac6aeeb0dc to your computer and use it in GitHub Desktop.

Revisions

  1. ta-riq created this gist Dec 11, 2017.
    9 changes: 9 additions & 0 deletions comment-classification.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    Php supports 'C', 'C++' and Unix shell-style (Perl style) comments. For example:

    <?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
    ?>
    37 changes: 37 additions & 0 deletions comment-styles.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    <?php

    //======================================================================
    // CATEGORY LARGE FONT
    //======================================================================

    //-----------------------------------------------------
    // Sub-Category Smaller Font
    //-----------------------------------------------------

    /* Title Here Notice the First Letters are Capitalized */

    # Option 1
    # Option 2
    # Option 3

    /*
    * This is a detailed explanation
    * of something that should require
    * several paragraphs of information.
    */

    // This is a single line quote.
    ?>


    <?php

    <!------------------------Text1----------------------START-->
    echo "Some text goes here";
    <!------------------------Text1----------------------END-->

    <!------------------------Text2----------------------START-->
    echo "Some text goes here";
    <!------------------------Text2----------------------END-->

    ?>
    17 changes: 17 additions & 0 deletions comments-are-not-taking-processing-power.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    Comments do NOT take up processing power.

    So, for all the people who argue that comments are undesired because they take up processing power now have no reason to comment ;)

    <?php

    // Control
    echo microtime(), "<br />"; // 0.25163600 1292450508
    echo microtime(), "<br />"; // 0.25186000 1292450508

    // Test
    echo microtime(), "<br />"; // 0.25189700 1292450508
    # TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
    # .. Above comment repeated 18809 times ..
    echo microtime(), "<br />"; // 0.25192100 1292450508

    ?>
    22 changes: 22 additions & 0 deletions dont-comment-like-this.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    Make sure you don't nest 'C' style comments. It is easy to make this mistake if you are trying to comment out a large block of code.

    <?php
    /*
    echo 'This is a test'; /* This comment will cause a problem */
    */
    ?>



    Be careful when commenting out regular expressions.

    E.g. the following causes a parser error.
    <?php

    /*
    $f->setPattern('/^\d.*/');

    */

    ?>