PHP Classes

File: compactor.example1.php

Recommend this page to a friend!
  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: 14 years ago
Size: 552 bytes


Class file image Download

require_once 'compactor.php';

$html = file_get_contents('');

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

For more information send a message to info at phpclasses dot org.