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.

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

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
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

MovieClip leeren (AS3)

Ich war wirklich besorgt um meine bachelorarbeit schreiben lassen​ (https://xn--ghostwriter-sterreich-sec.at/bachelorarbeit-schreiben-lassen/). ...

Geschrieben von Farebn am 26.04.2024 22:50:34
Forum: Grafik / Design / Flash ...
Berechnungen durchführen

Hallo liebe Forenmitglieder, meine erste frage ist zum Aufbau meiner kleinen Berechnungswebseite, nichts kommerzielles, soll nur eine Anwendung f ...

Geschrieben von matze511 am 21.04.2024 21:42:37
Forum: PHP Developer Forum
Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor