Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Binary-safe file read
<?php fread(resource $stream, int $length): string|false
<?php Loop::addReadStream(STDIN, function ($stream) {

    $chunk = fread($stream, 64 * 1024);




    if ($chunk === '') {
<?php Loop::addReadStream($stream, function ($stream) {

    $chunk = fread($stream, 64 * 1024);




    if ($chunk === '') {
<?php     Loop::addReadStream($stream, function ($stream) {

        $chunk = fread($stream, 64 * 1024);




        if ($chunk === '') {
<?php         $loop = $this->loop;

        $received =& $this->received;

        $loop->addReadStream($output, function ($output) use ($loop, &$received) {

            $chunk = fread($output, 1024);

            if ($chunk === '') {

                $received .= 'X';

                $loop->removeReadStream($output);
<?php         $loop = $this->loop;

        $loop->addReadStream($stream, function ($stream) use ($loop) {

            $data = fread($stream, 1024);

            if ($data !== '') {

                return;

            }