OpenSwoole\Process::write ( string $data ) : int

25.x is outdated, please check the latest version 26.x


Latest version: pecl install openswoole-26.2.0

Declaration

<?php OpenSwoole\Process::write ( string $data ) : int

Parameters

data

the data string write to the process

Return

length

The length of data sent

Description

Write data into the pipe between the parent process and child processes.

Example

<?php
$process = new OpenSwoole\Process(function($worker){
    echo "the pid of child process is " . $worker->pid . "\n";
    echo "the file descriptor of pipe is " . $worker->pipe . "\n";

    $res = $worker->write("Hello main process\n");
    var_dump(strlen("Hello main process\n"));
    var_dump($res);

    $worker->name("php child process");
}, FALSE);

$process->start();

usleep(100);

echo $process->read();
Last updated on February 28, 2026