Login   Register  
PHP Classes
elePHPant
Icontem

File: compactor.example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oliver Lillie  >  HTML Compactor  >  compactor.example1.php  >  Download  
File: compactor.example1.php
Role: Example script
Content type: text/plain
Description: Example File 1
Class: HTML Compactor
Reduce HTML document size by removing white-spaces
Author: By
Last change: added demo size test
Date: 2008-01-13 11:41
Size: 552 bytes
 

Contents

Class file image Download
<?php

    
require_once 'compactor.php';

    
$html file_get_contents('http://www.bbc.co.uk');

    
$size_before mb_strlen($html'8bit');
    
    
$compactor = new Compactor(array(
        
'buffer_echo' => false
    
));
    
$html $compactor->squeeze($html);
    
    
$size_after mb_strlen($html'8bit');
    
    echo 
'With whitespace removed the size of the HTML file has been shrunk from '.round($size_before/10242).'KB to '.round($size_after/10242).'KB saving '.round((1-($size_after/$size_before))*1002).'%<br />
-----------------<br />
<br />'
.$html;