eio_open

(PECL eio >= 0.0.1dev)

eio_openOpens a file

Beschreibung

eio_open(
    string $path,
    int $flags,
    int $mode,
    int $pri,
    callable $callback,
    mixed $data = NULL
): resource

eio_open() opens file specified by path in access mode mode with

Parameter-Liste

path

Path of the file to be opened.

Warnung

In some SAPIs(e.g. PHP-FPM) it could fail, if you don't specify full path.

flags

One of EIO_O_* constants, or their combinations. EIO_O_* constants have the same meaning, as their corresponding O_* counterparts defined in fnctl.h C header file. Default is EIO_O_RDWR.

mode

One of EIO_S_I* constants, or their combination (via bitwise OR operator). The constants have the same meaning as their S_I* counterparts defined in » sys/stat.h C header file. Required, if a file is created. Otherwise ignored.

pri

The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or null. If null passed, pri internally is set to EIO_PRI_DEFAULT.

callback

callback function is called when the request is done. It should match the following prototype:

void callback(mixed $data, int $result[, resource $req]);
data

is custom data passed to the request.

result

request-specific result value; basically, the value returned by corresponding system call.

req

is optional request resource which can be used with functions like eio_get_last_error()

data

Arbitrary variable passed to callback.

Rückgabewerte

eio_open() returns file descriptor in result argument of callback on success; otherwise, result is equal to -1.

Beispiele

Beispiel #1 eio_open() example

<?php
$temp_filename 
"eio-temp-file.tmp";

/* Is called when eio_close() finishes */
function my_close_cb($data$result) {
 
// Zero indicates success
    
var_dump($result == 0);
 @
unlink($data);
}

/* Is called when eio_open() finishes */
function my_file_opened_callback($data$result) {
 
// $result should contain the file descriptor
    
var_dump($result 0);

    if (
$result 0) {
  
// Close the file
        
eio_close($resultEIO_PRI_DEFAULT"my_close_cb"$data);
        
eio_event_loop();
    }
}

// Create new file for reading and writing
// Deny group and others to do anything with that file
eio_open($temp_filenameEIO_O_CREAT EIO_O_RDWREIO_S_IRUSR EIO_S_IWUSR,
  
EIO_PRI_DEFAULT"my_file_opened_callback"$temp_filename);
eio_event_loop();
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

bool(true)
bool(true)

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

Abfrage in Datenbank

Als Zeiger für die Fremdschlüsselspalte in der Yardmanagement-Tabelle verwenden Sie immer den Hauptschlüssel der Stellplatztabelle. Dieser Frem ...

Geschrieben von waderatke am 30.05.2024 04:49:31
Forum: SQL / Datenbanken
Abfrage über mehrere Spalten und Gruppierung

Sowohl der Zeitrahmen als auch die Verfahren müssen anpassbar sein, da die Dauer mit jedem Monat länger wird. Darüber hinaus müssen Prozesse a ...

Geschrieben von waderatke am 30.05.2024 04:43:42
Forum: SQL / Datenbanken
Finden Sie die Bestellungen des letzten Monats und die Gesamtausgaben

Ich möchte alle Kunden finden, die im letzten Monat eine Bestellung aufgegeben haben, und den Gesamtbetrag, den jeder Kunde ausgegeben hat. Wenn ...

Geschrieben von Gast am 28.05.2024 11:54:53
Forum: SQL / Datenbanken
PHP cURL Error

Hello I am facing an issue with cURL in my PHP application. When trying to make a secure HTTPS request, I am getting the following error: cURL e ...

Geschrieben von nolanmaris am 27.05.2024 18:27:56
Forum: PHP Developer Forum