Tonbrand Software Logo
Home Products Downloads Reviews  Purchase Support Contact 
 

This example shows how you can tidy up code and save many bytes

Below are the first 65 lines of the WordPress file 'class-pop3.php'.
WordPress is a free semantic personal publishing platform to make
working with your blogging software easier.
Note the large number of comment lines and waste white space.
<?php
 
    /**
    * mail_fetch/setup.php
    *
    * Copyright (c) 1999-2002 The SquirrelMail Project Team
    *
    * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
    * Modified by Philippe Mingo 2001 mingo@rotedic.com
    * An RFC 1939 compliant wrapper class for the POP3 protocol.
    *
    * Licensed under the GNU GPL. For full terms see the file COPYING.
    *
    * pop3 class
    *
    * $Id: class-pop3.php 2066 2005-01-07 01:29:49Z saxmatt $
    */
 
class  POP3  {
    var $ERROR        = '';
 
    var $TIMEOUT     = 60;
 
 
    var $COUNT        = -1;
 
    var $BUFFER       = 512;     
 
 
 
    var $FP              = '';
 
 
    var $MAILSERVER = '';
 
    var $DEBUG        = FALSE;
 
 
 
    var $BANNER       = '';
 
 
    var $RFC1939      = TRUE;
 
 
    var $ALLOWAPOP = FALSE;
 
 
 
//  Error string.
 
//  Default timeout before giving up on a
//  network operation.
 
//  Mailbox msg count
 
//  Socket buffer for socket fgets() calls.
//  Per RFC 1939 the returned line a POP3
//  server can send is 512 bytes.
 
//  The connection to the server's
//  file descriptor
 
//  Set this to hard code the server name
 
//  set to true to echo pop3
//  commands and responses to error_log
//  this WILL log passwords!
 
//  Holds the banner returned by the
//  pop server - used for apop()
 
//  Set by noop(). See rfc1939.txt
//
 
//  Allow or disallow apop()
//  This must be set to true
//  manually
    function POP3 ( $server = '', $timeout = '' ) {
        settype($this->BUFFER,"integer");
        if( !empty($server) ) {
          // Do not allow programs to alter MAILSERVER
          // if it is already specified. They can get around
          // this if they -really- want to, so don't count on it.
          if(empty($this->MAILSERVER))
              $this->MAILSERVER = $server;
        }
        if(!empty($timeout)) {
          settype($timeout,"integer");
          $this->TIMEOUT = $timeout;
          set_time_limit($timeout);
        }
        return true;
    }
// More functions to follow
?>
Below is the same code but optimized by HTML-Optimizer.
1857 bytes have been saved which is 78%.
Your original code is not touched. You see the code of the duplicate file.
<?php
class POP3 {
var $ERROR = '';
var $TIMEOUT = 60;
var $COUNT = -1;
var $BUFFER = 512;
var $FP = '';
var $MAILSERVER = '';
var $DEBUG = FALSE;
var $BANNER = '';
var $RFC1939 = TRUE;
var $ALLOWAPOP = FALSE;
function POP3 ( $server = '', $timeout = '' ) {
settype($this->BUFFER,"integer");
if( !empty($server) ) {
if(empty($this->MAILSERVER))
$this->MAILSERVER = $server;
}
if(!empty($timeout)) {
settype($timeout,"integer");
$this->TIMEOUT = $timeout;
set_time_limit($timeout);
}
return true;
}
?>
If you want to verify what we advertise, you may download the zipped shortened copy of the file 'class-pop3.php' and optimize it yourself by simply dropping it on the drop spot of one of our programs.
Copyright (©) 2012 Tonbrand Software. All rights reserved. Back to top