Keine Cache-Version


Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

Rechercher une fonction PHP

Phar::webPhar

(PHP 5 >= 5.3.0, PHP 7, PECL phar >= 2.0.0)

Phar::webPharmapPhar for web-based phars. front controller for web applications

Beschreibung

final public static Phar::webPhar ([ string $alias [, string $index = "index.php" [, string $f404 [, array $mimetypes [, callable $rewrites ]]]]] ) : void

Phar::mapPhar() for web-based phars. This method parses $_SERVER['REQUEST_URI'] and routes a request from a web browser to an internal file within the phar archive. In essence, it simulates a web server, routing requests to the correct file, echoing the correct headers and parsing PHP files as needed. This powerful method is part of what makes it easy to convert an existing PHP application into a phar archive. Combined with Phar::mungServer() and Phar::interceptFileFuncs(), any web application can be used unmodified from a phar archive.

Phar::webPhar() should only be called from the stub of a phar archive (see here for more information on what a stub is).

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Parameter-Liste

alias

The alias that can be used in phar:// URLs to refer to this archive, rather than its full path.

index

The location within the phar of the directory index.

f404

The location of the script to run when a file is not found. This script should output the proper HTTP 404 headers.

mimetypes

An array mapping additional file extensions to MIME type. If the default mapping is sufficient, pass an empty array. By default, these extensions are mapped to these MIME types:

<?php
$mimes 
= array(
    
'phps' => Phar::PHPS// pass to highlight_file()
    
'c' => 'text/plain',
    
'cc' => 'text/plain',
    
'cpp' => 'text/plain',
    
'c++' => 'text/plain',
    
'dtd' => 'text/plain',
    
'h' => 'text/plain',
    
'log' => 'text/plain',
    
'rng' => 'text/plain',
    
'txt' => 'text/plain',
    
'xsd' => 'text/plain',
    
'php' => Phar::PHP// parse as PHP
    
'inc' => Phar::PHP// parse as PHP
    
'avi' => 'video/avi',
    
'bmp' => 'image/bmp',
    
'css' => 'text/css',
    
'gif' => 'image/gif',
    
'htm' => 'text/html',
    
'html' => 'text/html',
    
'htmls' => 'text/html',
    
'ico' => 'image/x-ico',
    
'jpe' => 'image/jpeg',
    
'jpg' => 'image/jpeg',
    
'jpeg' => 'image/jpeg',
    
'js' => 'application/x-javascript',
    
'midi' => 'audio/midi',
    
'mid' => 'audio/midi',
    
'mod' => 'audio/mod',
    
'mov' => 'movie/quicktime',
    
'mp3' => 'audio/mp3',
    
'mpg' => 'video/mpeg',
    
'mpeg' => 'video/mpeg',
    
'pdf' => 'application/pdf',
    
'png' => 'image/png',
    
'swf' => 'application/shockwave-flash',
    
'tif' => 'image/tiff',
    
'tiff' => 'image/tiff',
    
'wav' => 'audio/wav',
    
'xbm' => 'image/xbm',
    
'xml' => 'text/xml',
);
?>

rewrites

The rewrites function is passed a string as its only parameter and must return a string or FALSE.

If you are using fast-cgi or cgi then the parameter passed to the function is the value of the $_SERVER['PATH_INFO'] variable. Otherwise, the parameter passed to the function is the value of the $_SERVER['REQUEST_URI'] variable.

If a string is returned it is used as the internal file path. If FALSE is returned then webPhar() will send a HTTP 403 Denied Code.

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Rückgabewerte

Es wird kein Wert zurückgegeben.

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Fehler/Exceptions

Throws PharException when unable to open the internal file to output, or if called from a non-stub. If an invalid array value is passed into mimetypes or an invalid callback is passed into rewrites, then UnexpectedValueException is thrown.

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Beispiele

Beispiel #1 A Phar::webPhar() example

With the example below, the created phar will display Hello World if one browses to /myphar.phar/index.php or to /myphar.phar, and will display the source of index.phps if one browses to /myphar.phar/index.phps.

<?php
// creating the phar archive:
try {
    
$phar = new Phar('myphar.phar');
    
$phar['index.php'] = '<?php echo "Hello World"; ?>';
    
$phar['index.phps'] = '<?php echo "Hello World"; ?>';
    
$phar->setStub('<?php
Phar::webPhar();
__HALT_COMPILER(); ?>'
);
} catch (
Exception $e) {
    
// handle error here
}
?>

Erste Seite von PHP-Handbuch Inhaltsverzeichnis Haut

Siehe auch

  • Phar::mungServer() - Defines a list of up to 4 $_SERVER variables that should be modified for execution
  • Phar::interceptFileFuncs() - Instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions

Finde eine PHP-Funktion

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 30/01/2003, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/php-rf-phar.webphar.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : http://php.net

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut