note 38886 added to function.gzfile

From: Date: Sat, 10 Jan 2004 02:01:22 +0000
Subject: note 38886 added to function.gzfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-63233@lists.php.net to get a copy of this message
For those who search for a function similar to file_get_contents but for gzip-files, here is one ;) This is actually a port of the code-snippet I've posted at http://www.php.net/file_get_contents Note: filesize can't be used here, because the length-paramenter of gzread is used for the uncompressed and not for the compressed content. <?php if (!function_exists('gzfile_get_contents')) { function gzfile_get_contents($filename, $use_include_path = 0) { $file = @gzopen($filename, 'rb', $use_include_path); if ($file) { $data = ''; // just to be safe. Dunno, if this is really needed while (!gzeof($file)) $data .= gzread($file, 1024); gzclose($file); } return $data; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.gzfile.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38886 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38886&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38886&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63233) next »