Reputation:
i faced PHP: Call to undefined function gzdecode() error few days back so i have been using this in php
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
}
ref: PHP: Call to undefined function gzdecode()
i found this old code snippet while looking in old php files , so can i use above code instead of this one ?
function gzdecode($data) {
$g=tempnam('/tmp', 'php-gz');
@file_put_contents($g, $data);
ob_start();
readgzfile($g);
$d=ob_get_clean();
unlink($g);
return $d;
}
Upvotes: 1
Views: 1215
Reputation: 7601
If you have access to your php.ini, simply enable the zlib
extension to use gzencode
. Each compression method has some slight differences.
Please read an abstract of this answer https://stackoverflow.com/a/621987/382536 by @thomasrutter
All of these are usable. I would use gzencode() because it is self-contained; its output is the same as if you had used the gzip command line tool.
There is not really much difference between the three.
Upvotes: 1