Phar::interceptFileFuncs

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

Phar::interceptFileFuncsInstructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions

Beschreibung

final public static Phar::interceptFileFuncs(): void

instructs phar to intercept fopen(), readfile(), file_get_contents(), opendir(), and all of the stat-related functions. If any of these functions is called from within a phar archive with a relative path, the call is modified to access a file within the phar archive. Absolute paths are assumed to be attempts to load external files from the filesystem.

This function makes it possible to run PHP applications designed to run off of a hard disk as a phar application.

Parameter-Liste

No parameters.

Rückgabewerte

Beispiele

Beispiel #1 A Phar::interceptFileFuncs() example

<?php
Phar
::interceptFileFuncs();
include 
'phar://' __FILE__ '/file.php';
?>

Assuming that this phar is at /path/to/myphar.phar and it contains file.php and file2.txt, if file.php contains this code:

Beispiel #2 A Phar::interceptFileFuncs() example

<?php
echo file_get_contents('file2.txt');
?>

Normally PHP would search the current directory for file2.txt, which would translate as the directory of file.php, or the current directory of a command-line user. Phar::interceptFileFuncs() instructs PHP to consider the current directory to be phar:///path/to/myphar.phar/ and so opens phar:///path/to/myphar.phar/file2.txt in the above example code.

Hier Kannst Du einen Kommentar verfassen


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

Total Commander 11.00 (final) ist verfügbar!

Total Commander, ein beliebter Datei-Manager, hat kürzlich seine neueste Version, 11.00, veröffentlicht. Mit einer Vielzahl von neuen Funktionen und Korrekturen bietet diese Version den Benutzern ein verbessertes und optimiertes Erlebnis. ...

admin

Autor : admin
Kategorie: Software-Updates

Welche Technologien sollte ein PHP Programmierer beherrschen?

In der heutigen digitalen Welt ist die Rolle eines PHP Programmierers von großer Bedeutung. ...

admin

Autor : admin
Kategorie: Dies und Das

PHPUnit in der Version 10 erschienen

PHPUnit in der Version 10 erschienen

Das beliebte Testframeworks PHPUnit ist in der Version 10 erschienen und steht zum Download bereit ...

TheMax

Autor : TheMax
Kategorie: Software & Web-Development

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

Fragen zu PHP-Syntax

Dankeschön, deine Erklärungen lassen mich Beides schon einmal besser nachvollziehen. Bei 2) hatte ich mittlerweile etwas zu Namensräumen gefund ...

Geschrieben von BrotherJ am 12.09.2023 08:05:17
Forum: PHP Developer Forum
Datei Prüfung - Alles was zwischen /* und */ steht, einfärben.

In deinem Beispiel endet der Kommentar in Zeile 11. Die Zeilen 12 bis 16 sind nicht mehr eingeschlossen, denn Kommentarzeichen kann man so nicht v ...

Geschrieben von reddighamburg am 12.09.2023 00:57:14
Forum: PHP Developer Forum
Fragen zu PHP-Syntax

zu 1) Hier geht es um Typensicherheit. Das : Response sagt nichts anderes, als dass der zurückgegebene Wert in jedem Fall vom Typ Response ist. A ...

Geschrieben von reddighamburg am 12.09.2023 00:31:02
Forum: PHP Developer Forum
Google findet die Seite einfach nicht...

Hey, Es tut mir leid zu hören, dass du Schwierigkeiten mit der Indexierung deines Blogs hast. In solchen Fällen ist es wichtig, verschiedene As ...

Geschrieben von Nikolla am 08.09.2023 12:31:56
Forum: SEO - Suchmaschinen Tricks und Tipps