(PHP Extension) Ungzip Base64 String
Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$gzip = new CkGzip();
$gzipBase64 = 'H4sIAAAAAAAE ... X6aZjXO3EwAA';
$bd = new CkBinData();
$success = $bd->AppendEncoded($gzipBase64,'base64');
$success = $gzip->UncompressBd($bd);
if ($success != true) {
print $gzip->lastErrorText() . "\n";
exit;
}
$strXml = $bd->getString('utf-8');
print 'XML:' . "\n";
print $strXml . "\n";
?>
|