Nesting Block Comments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    Nesting Block Comments

    Has anybody got a trick for commenting out blocks of code that contain block comments.
    This would be on a temporary basis and only used in degugging.

    I vaguely remember doing something in 'C' that used dates and CONSTANTS
    and was quite professional.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You could try using a heredoc string to comment it out...

    Like:
    [code=php]<?php
    class foo {

    private $name;

    /**
    * A constructor!
    */
    public function __construct($na me) {
    $this->name = $name;
    }

    /**
    * Is it a bird? Or a plane?
    */
    function bar() {
    echo $this->oof();

    $void <<< DEBUG
    /** Commented out for debugging purposes! **/
    }

    /**
    * This needs to be commented out
    */
    function oof {
    return "No! It's a {$this->name}!";
    }
    DEBUG;

    } // To close the foo function while debugging
    }
    ?> [/code]

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      the only thing I can think of is destroying the closing block comment tag. should be OK for debugging.

      Comment

      Working...