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.

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

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-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

Warning: Undefined variabl

Your article presents comprehensive and comprehensible information. I gained knowledge from this article that I had previously lacked. While I gen ...

Geschrieben von poppy12 am 30.05.2024 09:58:23
Forum: PHP Developer Forum
PHP 8.3.3 - App kann auf dem PC nicht ausgeführt werden

Many thanks for the valuable information you provide. In the future, I hope you will continue to provide everyone with as many excellent postings ...

Geschrieben von poppy12 am 30.05.2024 09:56:42
Forum: PHP Developer Forum
Schleifenproblem für MYSQL mit gleichen INPUT Feldnamen

This one-of-a-kind game has sparked a lot of attention. In poppy playtime (https://poppy-playtime.io), you must visit the Playtime toy factory. Th ...

Geschrieben von poppy12 am 30.05.2024 09:54:26
Forum: PHP Developer Forum
Seite neu Laden

Thank you very much for the excellent information you provided. In the future, I hope you will continue to provide everyone with as many fantastic ...

Geschrieben von dordle2 am 30.05.2024 09:52:03
Forum: Fragen/Vorschläge zum Forum