UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Web Hosting and Domains > PHP Hosting

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-09-2007, 08:35
new member
 
Join Date: Sep 2007
Posts: 3
Default How to remove tabs, line breaks, unneeded spaces, etc?

I am trying to save a little bandwidth by removing line breaks, tabs, unneeded spaces, etc. that you would see in a browser's view source. Is there a way of doing this when I'm using a php free template class?

Example:
Google.com. If you view their source, the code is cropped.

Info:
I have read some information regarding php's ob_start but I am not sure if that would apply to me as the examples I've seen echo's the buffer, whereas the template class is derived from phpbb and it has it's own $template method to make the output.

Example of method I use:
$tpl->set_filenames(array(
'body' => 'index.tpl')
);
$tpl->loadfile('body');
$tpl->pparse('body');

My HTML code is in index.tpl, and the PHP code is in index.php. The $tpl call's the template class and builds the page on pparse.
Additional Details

9 months ago
Jan: php.net does not have a forum, and I am hoping someone here might know!

Cva: That is bad advice! The way it is suppose to be done is proccessing the output, while leaving the original code untouched, as it should.
Reply With Quote
  #2 (permalink)  
Old 17-09-2007, 14:05
mephisto's Avatar
Senior Member
 
Join Date: Feb 2007
Location: Darlington
Posts: 100
Send a message via ICQ to mephisto Send a message via MSN to mephisto
Default

Don't know how php free template works, but if you can capture the output, then you would be able to pass it through tidy and then run a regular expression to remove the new lines in the code.

PHP Code:
<?php
$output 
// code to get output

$tidy = new tidy();
$output $tidy->repairString($output, array (
    
"add-xml-decl"      => true,
    
"indent"            => true,
    
"vertical-space"    => false,
    
"indent-spaces"     => 0,
    
"output-xhtml"      => true,
    
"output-encoding"   => "utf8",
    
"tidy-mark"         => false,
    
"DocType"           => "-//W3C//DTD XHTML 1.1//EN",
    
"merge-divs"        => false,
    
"wrap"              => 0,
    
"accessibility-check"   => 3,
    
"output-bom"        => false
));

$output preg_replace("/\r?\n/m"""$output);

// display the output
echo $output;
exit;
w
?>
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:32.

 

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

knowledgebase articles

popular blog categories