Login   Register  
PHP Classes
elePHPant
Icontem

File: buffer.inc

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Shaun Thomas  >  cache  >  buffer.inc  >  Download  
File: buffer.inc
Role: ???
Content type: text/plain
Description: Buffer Class
Class: cache
Author: By
Last change:
Date: 2001-06-07 21:55
Size: 2,457 bytes
 

Contents

Class file image Download
<?PHP
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //
// Package : buffer              Version : 1.0
// Date    : 01/03/2001          Author  : Shaun Thomas
// Req     : PHP 3.0               Type  : Class
//
// Description:
// ------------
// Every once in a while, a buffer is needed to store information before
// it is presented.  Since PHP's buffer system is designed only to control
// *when* things print, and not what the buffer contains, this library
// was written.  Just to make things easy, this is a class structure.
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //

class CBuffer
{
  var $buff;     // Our buffer.

  // -------------------------------------------------- //
  // Starts the buffer by redirecting all output to
  // the php output buffer system.
  // -------------------------------------------------- //
  function start()
  {
    ob_start();

  } // End function start.


  // -------------------------------------------------- //
  // Updates our buffer to contain the latest and
  // greatest.
  // -------------------------------------------------- //
  function freshen()
  {
    $this->buff = ob_get_contents();

  } // End function freshen.


  // -------------------------------------------------- //
  // Prints the buffer, emulates a sort of double -
  // buffer, since it does not update the current state
  // of our buffer variable.
  // -------------------------------------------------- //
  function dump()
  {
    print $this->buff;

  } // End function dump.


  // -------------------------------------------------- //
  // Stops and clears the output buffer without doing
  // anything else.  Keeps us from accidently printing.
  // -------------------------------------------------- //
  function stop()
  {
    ob_end_clean();

  } // End function stop.


  // -------------------------------------------------- //
  // Changes the value of the buffer.  Basically a
  // wrapper for str_replace to shorten syntax.
  // -------------------------------------------------- //
  function replace($from, $to)
  {
    $this->buff = str_replace($from,$to,$this->buff);

  } // End function replace.

}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //
// End buffer class
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //
?>