eio_grp

(PECL eio >= 0.0.1dev)

eio_grpCreates a request group

Beschreibung

eio_grp(callable $callback, string $data = NULL): resource

eio_grp() creates a request group.

Parameter-Liste

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_grp() returns request group resource on success,Bei einem Fehler wird false zurückgegeben..

Beispiele

Beispiel #1 eio_grp() example

<?php
$temp_filename 
dirname(__FILE__) ."/eio-file.tmp";
$fp fopen($temp_filename"w");
fwrite($fp"some data");
fclose($fp);
$my_file_fd NULL;

/* Is called when the group requests are done */
function my_grp_done($data$result) {
 
// Remove the file, if it still exists
 
@unlink($data);
}

/* Is called when the temporary file is opened */
function my_grp_file_opened_callback($data$result) {
 global 
$my_file_fd$grp;

 
$my_file_fd $result;

 
$req eio_read($my_file_fd40,
   
EIO_PRI_DEFAULT"my_grp_file_read_callback");
 
eio_grp_add($grp$req);
}

/* Is called when the file is read */
function my_grp_file_read_callback($data$result) {
 global 
$my_file_fd$grp;

 
var_dump($result);

 
// Create request to close the file
 
$req eio_close($my_file_fd);

 
// Add request to the group
 
eio_grp_add($grp$req);
}

// Create request group
$grp eio_grp("my_grp_done"$temp_filename);

// Create request
$req eio_open($temp_filenameEIO_O_RDWR EIO_O_APPEND NULL,
  
EIO_PRI_DEFAULT"my_grp_file_opened_callback"NULL);

// Add request to the group
eio_grp_add($grp$req);

// Process requests
eio_event_loop();
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

string(4) "some"

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

"Baustellen" endlich angehen?

Hey! Good on you for tackling those projects. Lockdown definitely offers a chance to get things done. I'm using the time to finally organize my sp ...

Geschrieben von Coreyalmer am 30.01.2026 04:56:38
Forum: Off-Topic Diskussionen
Löschen nach einen gewissen Datum in einer TXT-Datenbank

It's common situation, especially when a text file keeps growing over time. Removing entries based on a date sounds like a sensible way to keep th ...

Geschrieben von kumarbr am 29.01.2026 14:40:18
Forum: Off-Topic Diskussionen
Große JSON-Dateien in PHP effizient streamen?

Don’t use json_decode() for GB-scale files. Use a streaming parser (SAX-style) like jsonstreamingparser, or redesign the JSON into newline-delim ...

Geschrieben von jackmarvia689 am 28.01.2026 10:41:56
Forum: PHP Developer Forum
Kalenderwoche auf Sonntag anfangen lassen

The heart of Udaipur is City Palace, a magnificent complex overlooking Lake Pichola. With its balconies, courtyards, and museums, the palace offer ...

Geschrieben von dehradunbite am 28.01.2026 08:48:33
Forum: PHP Developer Forum