1
|
|
|
<? |
|
|
|
|
2
|
|
|
require_once ("../phpwee.php"); |
3
|
|
|
|
4
|
|
|
$html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29"); |
5
|
|
|
$minified = PHPWee\Minify::html($html); |
6
|
|
|
echo print_performance_graph("Wikipedia",$minified,$html); |
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
$html = file_get_contents("http://www.codeproject.com/Articles/759094/Step-by-Step-PHP-Tutorials-for-Beginners-Creating"); |
10
|
|
|
$minified = PHPWee\Minify::html($html); |
11
|
|
|
echo print_performance_graph("The Code Project",$minified,$html); |
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
$html = file_get_contents("https://github.com/php/php-src"); |
15
|
|
|
$minified = PHPWee\Minify::html($html); |
16
|
|
|
print_performance_graph("GiHub",$minified,$html); |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
$html = file_get_contents("http://www.w3schools.com/php/"); |
20
|
|
|
$minified = PHPWee\Minify::html($html); |
21
|
|
|
print_performance_graph("W3Schools",$minified,$html); |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
$html = file_get_contents("http://searchturbine.com"); |
25
|
|
|
$minified = PHPWee\Minify::html($html); |
26
|
|
|
print_performance_graph("SearchTurbine",$minified,$html); |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/////////////////////////////////////////////////////////////// |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
function print_performance_graph($subject,$minified,$html){ |
33
|
|
|
$before = strlen(gzcompress($html)); |
34
|
|
|
$after = strlen(gzcompress($minified)); |
35
|
|
|
$improvement = 100 * (1-($after/$before)); |
36
|
|
|
echo "<table style='width:100%; border:1px solid grey;text-align:center'><tr><th colspan=3><b>$subject</th><tr><th>Gzipped Bytes Before PHPWee</th><th>Gzipped Bytes After PHPWee</th><th>% Performance Boost</th></tr><tr><td>$before before</td><td>$after after</td><td> $improvement % faster </td></table><br><br>"; |
37
|
|
|
} |
Short opening tags are disabled in PHP?s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.
As a precaution to avoid these problems better use the long opening tag
<?php
.