SplTempFileObject::__construct

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplTempFileObject::__constructConstruct a new temporary file object

Beschreibung

public SplTempFileObject::__construct(int $maxMemory = 2 * 1024 * 1024)

Construct a new temporary file object.

Parameter-Liste

maxMemory

The maximum amount of memory (in bytes, default is 2 MB) for the temporary file to use. If the temporary file exceeds this size, it will be moved to a file in the system's temp directory.

If maxMemory is negative, only memory will be used. If maxMemory is zero, no memory will be used.

Fehler/Exceptions

Throws a RuntimeException if an error occurs.

Beispiele

Beispiel #1 SplTempFileObject() example

This example writes a temporary file in memory which can be written to and read from.

<?php
$temp 
= new SplTempFileObject();
$temp->fwrite("This is the first line\n");
$temp->fwrite("And this is the second.\n");
echo 
"Written " $temp->ftell() . " bytes to temporary file.\n\n";

// Rewind and read what was written
$temp->rewind();
foreach (
$temp as $line) {
    echo 
$line;
}
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

Written 47 bytes to temporary file.

This is the first line
And this is the second.

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

U4GM Guide to Mistfall Hunter's Secret Statue Trial

At first light, Mistfall Hunter asks players to make a difficult choice: press deeper into the fog for one more relic, or return while the path is ...

Geschrieben von Ponti233 am 31.08.2026 09:38:24
Forum: Fragen/Vorschläge zum Forum
Helldivers 2 Bastion Tank Domination | U4GM

Helldivers 2 thrives on fast decisions, imperfect information, and the kind of teamwork that turns a difficult extraction into a story worth retel ...

Geschrieben von Ponti233 am 31.08.2026 09:08:33
Forum: PHP Developer Forum
U4GM's POE 2 Build: Better Earthquake Warrior

Path of Exile 2 is steadily developing into a more thoughtful action RPG, where preparation matters as much as quick reactions. For newcomers and ...

Geschrieben von Ponti233 am 31.08.2026 08:01:05
Forum: Tutorials
GTA V Gallivanter Warden SUV Guide | U4GM

Grand Theft Auto V remains one of the most active open-world games years after its original release, largely because its online world continues to ...

Geschrieben von Ponti233 am 31.08.2026 05:25:07
Forum: News / Kostenloses