note 42540 added to ref.zlib

From: Date: Thu, 20 May 2004 15:38:50 +0000
Subject: note 42540 added to ref.zlib
Groups: php.notes 
Request: Send a blank email to php-notes+get-69880@lists.php.net to get a copy of this message
/** * @return bool * @param string $in * @param string $out * @param string $param = "1" * @desc compressing the file with the zlib-extension */ function gzip ($in, $out, $param="1") { if (!file_exists ($in) || !is_readable ($in)) return false; if ((!file_exists ($out) && !is_writable (dirname ($out)) || (file_exists($out) && !is_writable($out)) )) return false; $in_file = fopen ($in, "rb"); if (!$out_file = gzopen ($out, "wb".$param)) { return false; } while (!feof ($in_file)) { $buffer = fgets ($in_file, 4096); gzwrite ($out_file, $buffer, 4096); } fclose ($in_file); gzclose ($out_file); return true; } /** * @return bool * @param string $in * @param string $out * @desc uncompressing the file with the zlib-extension */ function gunzip ($in, $out) { if (!file_exists ($in) || !is_readable ($in)) return false; if ((!file_exists ($out) && !is_writable (dirname ($out)) || (file_exists($out) && !is_writable($out)) )) return false; $in_file = gzopen ($in, "rb"); $out_file = fopen ($out, "wb"); while (!gzeof ($in_file)) { $buffer = gzread ($in_file, 4096); fwrite ($out_file, $buffer, 4096); } gzclose ($in_file); fclose ($out_file); return true; } ---- Manual Page -- http://www.php.net/manual/en/ref.zlib.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42540 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42540&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42540&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69880) next »