note 57357 deleted from function.gzwrite by mazzanet

From: Date: Sat, 01 Oct 2005 10:26:24 +0000
Subject: note 57357 deleted from function.gzwrite by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96126@lists.php.net to get a copy of this message
Note Submitter: quatrux at gmail dot com ---- Here are some functions I wrote which might be useful for others to use. <?php function gzput_file_contents($file, $data) { /* check if Directory exists */ if (is_dir($file)) { return FALSE; /* check if file exists and is Removed */ } elseif (is_file($file) AND !unlink($file)) { return FALSE; /* create new File with owner PHP */ } elseif (!touch($file)) { return FALSE; } /* Open and Store Data to File */ $gz = gzopen($file, 'w9'); if (gzputs($gz, $data) === FALSE) { return FALSE; } gzclose($gz); return TRUE; } function gzget_file_contents($file) { /* Check if is File */ if (!is_file($file)) { return FALSE; } $gzfile = implode(gzfile($file)); return $gzfile; } gzput_file_contents('test.txt.gz', 'This is my Test Message'); echo mime_content_type('test.txt.gz'); // application/x-gzip echo gzget_file_contents('test.txt.gz'); // This is my Test Message echo file_get_contents('test.txt.gz'); // Compressed Data ?>

« previous php.notes (#96126) next »