Phar::__construct

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 1.0.0)

Phar::__constructConstruct a Phar archive object

Beschreibung

public Phar::__construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, ?string $alias = null)

Parameter-Liste

filename

Path to an existing Phar archive or to-be-created archive. The file name's extension must contain .phar.

flags

Flags to pass to parent class RecursiveDirectoryIterator.

alias

Alias with which this Phar archive should be referred to in calls to stream functionality.

Fehler/Exceptions

Throws BadMethodCallException if called twice, UnexpectedValueException if the phar archive can't be opened.

Beispiele

Beispiel #1 A Phar::__construct() example

<?php
try {
    
$p = new Phar('/path/to/my.phar'FilesystemIterator::CURRENT_AS_FILEINFO FilesystemIterator::KEY_AS_FILENAME,
                  
'my.phar');
} catch (
UnexpectedValueException $e) {
    die(
'Could not open my.phar');
} catch (
BadMethodCallException $e) {
    echo 
'technically, this cannot happen';
}
// this works now
echo file_get_contents('phar://my.phar/example.txt');
// and works as if we had typed
echo file_get_contents('phar:///path/to/my.phar/example.txt');
?>

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

MMOexp Trading is at the heart of Monopoly Go strategy

Monopoly Go is more than just a childhood classic; it’s a timeless board game that has entertained and challenged players worldwide since its de ...

Geschrieben von mvptkfjb am 14.05.2026 09:26:29
Forum: Off-Topic Diskussionen
MMOexp MLB The Show 26: Ten Changes Could Make Game

I’ve played baseball video games since MLB Pennant Race on the PlayStation 1, and I’ve been covering sports titles for nearly two decades. Bas ...

Geschrieben von mvptkfjb am 14.05.2026 09:11:51
Forum: Off-Topic Diskussionen
MMOexp Chrono Odyssey emphasizes teamwork

Welcome to the vast, dynamic world of Chrono Odyssey, an open-world MMO set in the breathtaking land of Satara. Here, you’ll face battles and em ...

Geschrieben von mvptkfjb am 14.05.2026 08:10:48
Forum: Off-Topic Diskussionen
onew88com

new88 là nền tảng giải trí trực tuyến uy tín, mang đến cho người chơi trải nghiệm hiện đại với giao diện thân th ...

Geschrieben von onew88coms am 13.05.2026 13:00:21
Forum: Off-Topic Diskussionen