How to remove all comments from multiple PHP documents at once?

Asked

Viewed 517 times

0

How to remove all comments from multiple PHP documents at once?

  • Maybe Gulp or Grunt has something like this. Or Ctrl + H passing a regular expression on an IDE that has this function available

  • You can use a mini-fication: https://answall.com/q/100977/101 and https://answall.com/q/128042/101 and https://answall.com/q/88058/101

  • @Maniero, confused in the title of the topic. It’s not HTML, but PHP. However, the encoding minification worked perfectly. I used this site: http://www.cu.eu/php-minify/

1 answer

2


The ideal is to use a minification software. The only way to do it fully automatically and simply is like this. Even using an editor that accepts regular expressions, it is not easy to create a simple expression, imagine a complex one because it is not only catch the pattern, it has a series of patterns that are worth or not worth, including because the comment may be within a string, may be nested, may be part of another language code embedded in the main and other ways what seems comment is not

Parse code is too complex to leave for a very precarious tool. See more on: Comments weigh?.

Examples of minificators for PHP. In the comments have for HTML/CSS/HTML.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.