downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Fonctions Zlib> <Constantes pré-définies
[edit] Last updated: Fri, 25 May 2012

view this page in

Exemples

Cet exemple ouvre un fichier temporaire et y écrit une chaîne de test, puis, affiche le contenu de ce fichier, deux fois.

Exemple #1 Exemple avec Zlib

<?php

$filename 
tempnam('/tmp''zlibtest') . '.gz';
echo 
"<html>\n<head></head>\n<body>\n<pre>\n";
$s "Seulement un test, test, test, test, test, test, test, test!\n";

// ouvre un fichier en écriture, avec une compression maximale
$zp gzopen($filename"w9");

// écrit une chaîne dans le fichier
gzwrite($zp$s);

// ferme le fichier
gzclose($zp);

// ouvre un fichier en lecture
$zp gzopen($filename"r");

// lit 3 caractères
echo gzread($zp3);

// lit tout le contenu et ferme le fichier
gzpassthru($zp);
gzclose($zp);

echo 
"\n";

// ouvre un fichier et affiche le contenu (pour la deuxième fois).
if (readgzfile($filename) != strlen($s)) {
        echo 
"Erreur avec les fonctions zlib !";
}
unlink($filename);
echo 
"</pre>\n</body>\n</html>\n";

?>


add a note add a note User Contributed Notes Exemples
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites