PHP Doku:: Loads any phar archive with an alias - phar.loadphar.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzErweiterungen zur Datenkompression und ArchivierungPharThe Phar classPhar::loadPhar

Ein Service von Reinhard Neidl - Webprogrammierung.

The Phar class

<<Phar::isWritable

Phar::mapPhar>>

Phar::loadPhar

(PHP >= 5.3.0, PECL phar >= 1.0.0)

Phar::loadPharLoads any phar archive with an alias

Beschreibung

bool Phar::loadPhar ( string $filename [, string $alias ] )

This can be used to read the contents of an external Phar archive. This is most useful for assigning an alias to a phar so that subsequent references to the phar can use the shorter alias, or for loading Phar archives that only contain data and are not intended for execution/inclusion in PHP scripts.

Parameter-Liste

filename

the full or relative path to the phar archive to open

alias

The alias that may be used to refer to the phar archive. Note that many phar archives specify an explicit alias inside the phar archive, and a PharException will be thrown if a new alias is specified in this case.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Fehler/Exceptions

PharException is thrown if an alias is passed in and the phar archive already has an explicit alias

Beispiele

Beispiel #1 A Phar::loadPhar() example

Phar::loadPhar can be used anywhere to load an external Phar archive, whereas Phar::mapPhar should be used in a loader stub for a Phar.

<?php
try {
    
Phar::loadPhar('/path/to/phar.phar''my.phar');
    echo 
file_get_contents('phar://my.phar/file.txt');
} catch (
PharException $e) {
    echo 
$e;
}
?>

Siehe auch

  • Phar::mapPhar() - Reads the currently executed file (a phar) and registers its manifest


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)