how to remove comments from php files

Discussion in 'Programming' started by bluesmoke, Mar 12, 2008.

  1. #1
    Hello there.
    Wondering if there is such a way here I can remove all comments from script.For example i want to hide what script does and where it looks and what it refers to .I know it won't stop professional programmer from understanding but we need to stop amateurs to mode the code . And if I could just strip comments from the bulk files that would be awesome!
     
    bluesmoke, Mar 12, 2008 IP
  2. Randombase

    Randombase Peon

    Messages:
    224
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can do this with a regex like in Perl:
    open(f,"<file.php");
    foreach $line(<f>)
    {
    $line = s/\/\/(.*)$//;
    }
    Code (markup):
    This would also remove certain parts that are between quotes too :(
     
    Randombase, Mar 13, 2008 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The PHP obfuscator in my signature let's you choose which things to pull from your code. That way, if you only want comments pulled, that's all that will get pulled.

    I hope that helps.
     
    TwistMyArm, Mar 13, 2008 IP