Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher une fonction PHP

RarArchive::open

rar_open

(PECL rar >= 2.0.0)

RarArchive::open -- rar_openOpen RAR archive

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Description

Object oriented style (method):

public static RarArchive::open ( string $filename [, string $password = NULL [, callable $volume_callback = NULL ]] ) : RarArchive

Procedural style:

rar_open ( string $filename [, string $password = NULL [, callable $volume_callback = NULL ]] ) : RarArchive

Open specified RAR archive and return RarArchive instance representing it.

Note:

If opening a multi-volume archive, the path of the first volume should be passed as the first parameter. Otherwise, not all files will be shown. This is by design.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Parameters

filename

Path to the Rar archive.

password

A plain password, if needed to decrypt the headers. It will also be used by default if encrypted files are found. Note that the files may have different passwords in respect to the headers and among them.

volume_callback

A function that receives one parameter – the path of the volume that was not found – and returns a string with the correct path for such volume or NULL if such volume does not exist or is not known. The programmer should ensure the passed function doesn't cause loops as this function is called repeatedly if the path returned in a previous call did not correspond to the needed volume. Specifying this parameter omits the notice that would otherwise be emitted whenever a volume is not found; an implementation that only returns NULL can therefore be used to merely omit such notices.

Warning

Prior to version 2.0.0, this function would not handle relative paths correctly. Use realpath() as a workaround.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Return Values

Returns the requested RarArchive instance or FALSE on failure.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Changelog

Version Description
3.0.0 volume_callback was added.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Examples

Example #1 Object oriented style

<?php
$rar_arch 
RarArchive::open('encrypted_headers.rar''samplepassword');
if (
$rar_arch === FALSE)
    die(
"Failed opening file");
    
$entries $rar_arch->getEntries();
if (
$entries === FALSE)
    die(
"Failed fetching entries");

echo 
"Found " count($entries) . " files.\n";

if (empty(
$entries))
    die(
"No valid entries found.");
    
$stream reset($entries)->getStream();
if (
$stream === FALSE)
    die(
"Failed opening first file");

$rar_arch->close();

echo 
"Content of first one follows:\n";
echo 
stream_get_contents($stream);

fclose($stream);
?>

The above example will output something similar to:

Found 2 files.
Content of first one follows:
Encrypted file 1 contents.

Example #2 Procedural style

<?php
$rar_arch 
rar_open('encrypted_headers.rar''samplepassword');
if (
$rar_arch === FALSE)
    die(
"Failed opening file");
    
$entries rar_list($rar_arch);
if (
$entries === FALSE)
    die(
"Failed fetching entries");

echo 
"Found " count($entries) . " files.\n";

if (empty(
$entries))
    die(
"No valid entries found.");
    
$stream reset($entries)->getStream();
if (
$stream === FALSE)
    die(
"Failed opening first file");

rar_close($rar_arch);

echo 
"Content of first one follows:\n";
echo 
stream_get_contents($stream);

fclose($stream);
?>

Example #3 Volume Callback

<?php
/* In this example, there's a volume named multi_broken.part1.rar
 * whose next volume is named multi.part2.rar */
function resolve($vol) {
    if (
preg_match('/_broken/'$vol))
        return 
str_replace('_broken'''$vol);
    else
        return 
null;
}
$rar_file1 rar_open(dirname(__FILE__).'/multi_broken.part1.rar'null'resolve');
$entry $rar_file1->getEntry('file2.txt');
$entry->extract(nulldirname(__FILE__) . "/temp_file2.txt");
?>

Zoek een PHP-functie

Vertaling niet beschikbaar

De PHP-handleiding is nog niet in het Nederlands vertaald, dus het scherm is in het Engels. Als u wilt, kunt u het ook in het Frans of in het Duits raadplegen.

Als je de moed voelt, kun je je vertaling aanbieden ;-)

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 30/01/2003 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/php-rf-rararchive.open.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : http://php.net

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut