public function encode($data, $encoding = FORCE_GZIP, $level = 4)
    {
        // Verify that the server supports gzip compression before we attempt to gzip encode the data.
        if (!static::isSupported()) {
            throw new CompressException(
                'Your system does not support HTTP compression, please check zlib has benn enabled' .
                ' or zlib.output_compression in php.ini has set to "On".'
            );
        }

        // Verify that headers have not yet been sent, and that our connection is still alive.
        if ($this->checkHeadersSent()) {
            throw new CompressException('Header has been sent or connection is not alive, compression can not work.');
        }

        if (!$this->checkConnectionAlive()) {
            throw new CompressException('Connection is not alive, compression can not work.');
        }

        return gzencode((string) $data, $level, $encoding);
    }
public function encode($data, $encoding = FORCE_GZIP, $level = 4)
    {
        // Verify that the server supports gzip compression before we attempt to gzip encode the data.
        if (!static::isSupported()) {
            throw new CompressException(
                'Your system does not support HTTP compression, please check zlib has benn enabled' .
                ' or zlib.output_compression in php.ini has set to "On".'
            );
        }

        // Verify that headers have not yet been sent, and that our connection is still alive.
        if ($this->checkHeadersSent()) {
            throw new CompressException('Header has been sent or connection is not alive, compression can not work.');
        }

        if (!$this->checkConnectionAlive()) {
            throw new CompressException('Connection is not alive, compression can not work.');
        }

        return gzencode((string) $data, $level, $encoding);
    }
public function encode ( $ data , $ encoding = FORCE_GZIP , $ level = 4 ) { // Verify that the server supports gzip compression before we attempt to gzip encode the data. if ( ! static :: isSupported ( ) ) { throw new CompressException ( 'Your system does not support HTTP compression, please check zlib has benn enabled' . ' or zlib.output_compression in php.ini has set to "On".' ) ; } // Verify that headers have not yet been sent, and that our connection is still alive. if ( $ this -> checkHeadersSent ( ) ) { throw new CompressException ( 'Header has been sent or connection is not alive, compression can not work.' ) ; } if ( ! $ this -> checkConnectionAlive ( ) ) { throw new CompressException ( 'Connection is not alive, compression can not work.' ) ; } return gzencode ( ( string ) $ data , $ level , $ encoding ) ; }
Compress raw data.

@param string $data       The data to encode.
@param int    $encoding   The encoding mode. Can be FORCE_GZIP (the default) or FORCE_DEFLATE.
@param int    $level      The level of compression. Can be given as 0 for no compression up to 9
for maximum compression. If not given, the default compression level will
be the default compression level of the zlib library.

@return  string

@throws  CompressException
Compress raw data .