stream_wrapper_register

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

stream_wrapper_registerRegister a URL wrapper implemented as a PHP class

Beschreibung

stream_wrapper_register(string $protocol, string $class, int $flags = 0): bool

Allows you to implement your own protocol handlers and streams for use with all the other filesystem functions (such as fopen(), fread() etc.).

Parameter-Liste

protocol

The wrapper name to be registered. Valid protocol names must contain alphanumerics, dots (.), plusses (+), or hyphens (-) only.

class

The classname which implements the protocol.

flags

Should be set to STREAM_IS_URL if protocol is a URL protocol. Default is 0, local stream.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

stream_wrapper_register() will return false if the protocol already has a handler.

Beispiele

Beispiel #1 How to register a stream wrapper

<?php
$existed 
in_array("var"stream_get_wrappers());
if (
$existed) {
    
stream_wrapper_unregister("var");
}
stream_wrapper_register("var""VariableStream");
$myvar "";

$fp fopen("var://myvar""r+");

fwrite($fp"line1\n");
fwrite($fp"line2\n");
fwrite($fp"line3\n");

rewind($fp);
while (!
feof($fp)) {
    echo 
fgets($fp);
}
fclose($fp);
var_dump($myvar);

if (
$existed) {
    
stream_wrapper_restore("var");
}

?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

line1
line2
line3
string(18) "line1
line2
line3
"

Siehe auch

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 Maplestory Artale

Mesos are the lifeblood of Maplestory Artale, acting as buy Maplestory Artale Mesos (https://www.mmoexp.com/Artale/Mesos.html) the primary in-game ...

Geschrieben von JeansKeyzhu am 30.05.2026 08:35:09
Forum: PHP Developer Forum
MMOexp CFB 26 one key adjustment that can completely

Running the football in College Football 26 can feel frustrating at times. One game, your running back is buy College Football 26 Coins (https:// ...

Geschrieben von JeansKeyzhu am 30.05.2026 08:32:54
Forum: Fragen/Vorschläge zum Forum
MMOexp Diablo 4 to unleash devastating attacks more

Diablo 4 Season 13 has introduced several powerful builds across every class, but few are as explosive and satisfying as the Bone Spirit Necromanc ...

Geschrieben von JeansKeyzhu am 30.05.2026 08:31:05
Forum: PHP Developer Forum
SEO-URLs und MySQL

Scary Teacher 3D (https://scaryteacher-3d.io/) stealth gameplay strategies often focus on understanding Miss T's movement patterns before attempti ...

Geschrieben von sftad am 30.05.2026 05:33:22
Forum: SQL / Datenbanken