1 | <?php |
||
6 | class HtmlMinifier |
||
7 | { |
||
8 | private $replace = [ |
||
9 | '<!--(.*?)-->' => '', //remove comments |
||
10 | "/<\?php/" => '<?php ', |
||
11 | "/\n([\S])/" => '$1', |
||
12 | "/\r/" => '', // remove carrage return |
||
13 | "/\n/" => '', // remove new lines |
||
14 | "/\t/" => '', // remove tab |
||
15 | "/\s+/" => ' ', // remove spaces |
||
16 | ]; |
||
17 | /** |
||
18 | * @return null |
||
19 | */ |
||
20 | function minify($htmlString) |
||
24 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.