Removing comments from PHP

Sometimes it is enough to remove comments from your PHP code to make it not worth stealing, as a potential violator will spend more time figuring out what did you mean by all that, than writing his own version of the software to do the same job.

This very simple solution, based on an example in a forum here, does that for all files in the directory and its subdirectories.

  • find . -type f -name '*.php' | while read VAR; \
    do mv $VAR "$VAR-old"; php -wq "$VAR-old" > $VAR ; \
    unlink "$VAR-old"; done

Unlike obfuscators, it does not mess with your actual code.

The php options engaged here are:

-w             Output source with stripped comments and whitespace

-q             Quiet-mode. Suppress HTTP header output (CGI only).

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s